Cleanup avatars nextcloud handling

This commit is contained in:
the-djmaze 2024-06-24 16:23:18 +02:00
parent 0b494a13a5
commit 5a63b02782
2 changed files with 37 additions and 39 deletions

View file

@ -117,24 +117,22 @@
*/ */
addEventListener('DOMContentLoaded', () => { addEventListener('DOMContentLoaded', () => {
// rl.pluginSettingsGet('avatars', 'nextcloud'); // rl.pluginSettingsGet('avatars', 'nextcloud');
if (parent.OC) { if (parent.OC?.requestToken) {
const OC = () => parent.OC, const OC = parent.OC,
nsDAV = 'DAV:', nsDAV = 'DAV:',
nsNC = 'http://nextcloud.com/ns', nsNC = 'http://nextcloud.com/ns',
nsCard = 'urn:ietf:params:xml:ns:carddav', nsCard = 'urn:ietf:params:xml:ns:carddav',
getElementsByTagName = (parent, namespace, localName) => parent.getElementsByTagNameNS(namespace, localName), getElementsByTagName = (parent, namespace, localName) => parent.getElementsByTagNameNS(namespace, localName),
getElementValue = (parent, namespace, localName) => getElementValue = (parent, namespace, localName) =>
getElementsByTagName(parent, namespace, localName)?.item(0)?.textContent, getElementsByTagName(parent, namespace, localName)?.item(0)?.textContent;
generateUrl = path => OC().webroot + '/remote.php' + path; fetch(`${OC.webroot}/remote.php/dav/addressbooks/users/${OC.currentUser}/contacts/`, {
if (OC().requestToken) {
fetch(generateUrl(`/dav/addressbooks/users/${OC().currentUser}/contacts/`), {
mode: 'same-origin', mode: 'same-origin',
cache: 'no-cache', cache: 'no-cache',
redirect: 'error', redirect: 'error',
credentials: 'same-origin', credentials: 'same-origin',
method: 'REPORT', method: 'REPORT',
headers: { headers: {
requesttoken: OC().requestToken, requesttoken: OC.requestToken,
'Content-Type': 'application/xml; charset=utf-8', 'Content-Type': 'application/xml; charset=utf-8',
Depth: 1 Depth: 1
}, },
@ -162,7 +160,6 @@
} }
}); });
} }
}
}); });
ko.bindingHandlers.fromPic = { ko.bindingHandlers.fromPic = {

View file

@ -172,6 +172,7 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
if (\class_exists('OC') && isset(\OC::$server)) { if (\class_exists('OC') && isset(\OC::$server)) {
$aResult[] = \RainLoop\Plugins\Property::NewInstance('nextcloud')->SetLabel('Lookup Nextcloud Contacts') $aResult[] = \RainLoop\Plugins\Property::NewInstance('nextcloud')->SetLabel('Lookup Nextcloud Contacts')
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL) ->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
// ->SetAllowedInJs(true)
->SetDefaultValue(false); ->SetDefaultValue(false);
} }
*/ */