mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +00:00
v1.6.2: Fix owncloud 9 contact app which break our frontend
This commit is contained in:
parent
2990a5cbad
commit
3d71229767
@ -5,8 +5,9 @@
|
|||||||
<description>A app to sync SMS with your ownCloud</description>
|
<description>A app to sync SMS with your ownCloud</description>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Loic Blot</author>
|
<author>Loic Blot</author>
|
||||||
<version>1.6.0</version>
|
<version>1.6.2</version>
|
||||||
<requiremin>7</requiremin>
|
<requiremin>7</requiremin>
|
||||||
|
<requiremax>9</requiremin>
|
||||||
|
|
||||||
<ocsid>167289</ocsid>
|
<ocsid>167289</ocsid>
|
||||||
|
|
||||||
|
@ -98,7 +98,14 @@ class SmsController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$lastRead = $this->smsMapper->getLastReadDate($this->userId);
|
$lastRead = $this->smsMapper->getLastReadDate($this->userId);
|
||||||
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos));
|
$ocversion = \OCP\Util::getVersion();
|
||||||
|
$photoURL = preg_replace("#^VALUE=uri:#","",$r["PHOTO"], 1);
|
||||||
|
$photoversion = 1;
|
||||||
|
if (version_compare($ocversion[0].".".$ocversion[1].".".$ocversion[2], "9.0.0", ">=")) {
|
||||||
|
$photoversion = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos, "photo_version" => $photoversion));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +46,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
$scope.contacts = [];
|
$scope.contacts = [];
|
||||||
$scope.messages = [];
|
$scope.messages = [];
|
||||||
$scope.totalMessageCount = 0;
|
$scope.totalMessageCount = 0;
|
||||||
|
$scope.photoVersion = 1;
|
||||||
// Settings
|
// Settings
|
||||||
$scope.sendCountry = function () {
|
$scope.sendCountry = function () {
|
||||||
$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()});
|
$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()});
|
||||||
@ -299,8 +300,14 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
$scope.fetchInitialPeerList = function (jsondata) {
|
$scope.fetchInitialPeerList = function (jsondata) {
|
||||||
// Use a buffer for better jQuery performance
|
// Use a buffer for better jQuery performance
|
||||||
var peerListBuf = "";
|
var peerListBuf = "";
|
||||||
|
var photoPrefix = "";
|
||||||
var bufferedContacts = [];
|
var bufferedContacts = [];
|
||||||
|
|
||||||
|
$scope.photoVersion = jsondata["photo_version"];
|
||||||
|
if ($scope.photoVersion >= 2) {
|
||||||
|
photoPrefix = "data:image/png;base64,";
|
||||||
|
}
|
||||||
|
|
||||||
$.each(jsondata['phonelist'], function(id, val) {
|
$.each(jsondata['phonelist'], function(id, val) {
|
||||||
var fn, peerLabel, idxVal;
|
var fn, peerLabel, idxVal;
|
||||||
idxVal = id.replace(/\//g,' ');
|
idxVal = id.replace(/\//g,' ');
|
||||||
@ -314,7 +321,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
peerLabel = fn;
|
peerLabel = fn;
|
||||||
}
|
}
|
||||||
if (!inArray(peerLabel, bufferedContacts)) {
|
if (!inArray(peerLabel, bufferedContacts)) {
|
||||||
$scope.addContact({'label': peerLabel, 'nav': idxVal2, 'avatar': jsondata['photos'][peerLabel], 'unread' : 0});
|
$scope.addContact({'label': peerLabel, 'nav': idxVal2, 'avatar': photoPrefix + jsondata['photos'][peerLabel], 'unread' : 0});
|
||||||
bufferedContacts.push(peerLabel);
|
bufferedContacts.push(peerLabel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace OCA\OcSms\Lib;
|
namespace OCA\OcSms\Lib;
|
||||||
|
|
||||||
|
use \OCP\Util;
|
||||||
|
|
||||||
class ContactCache {
|
class ContactCache {
|
||||||
/**
|
/**
|
||||||
* @var array used to cache the parsed contacts for every request
|
* @var array used to cache the parsed contacts for every request
|
||||||
@ -89,8 +91,15 @@ class ContactCache {
|
|||||||
|
|
||||||
if (isset ($r["PHOTO"])) {
|
if (isset ($r["PHOTO"])) {
|
||||||
// Remove useless prefix
|
// Remove useless prefix
|
||||||
|
// @TODO detect owncloud version
|
||||||
|
$ocversion = \OCP\Util::getVersion();
|
||||||
$photoURL = preg_replace("#^VALUE=uri:#","",$r["PHOTO"], 1);
|
$photoURL = preg_replace("#^VALUE=uri:#","",$r["PHOTO"], 1);
|
||||||
$this->contactPhotos[$r["FN"]] = $photoURL;
|
if (version_compare($ocversion[0].".".$ocversion[1].".".$ocversion[2], "9.0.0", ">=")) {
|
||||||
|
$this->contactPhotos[$r["FN"]] = base64_encode($photoURL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->contactPhotos[$r["FN"]] = $photoURL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user