]> git.mxchange.org Git - friendica-addons.git/blobdiff - jappixmini/lib.js
Merge remote branch 'upstream/master'
[friendica-addons.git] / jappixmini / lib.js
index 1794def67f035f63ccdb885ec026756d60743d4b..a777a7fddfc069462f55468fedb4e64f5c0a50ca 100644 (file)
@@ -1,3 +1,9 @@
+//
+// Copyright 2012 "Leberwurscht" <leberwurscht@hoegners.de>
+//
+// This file is dual-licensed under the MIT license (see MIT.txt) and the AGPL license (see jappix/COPYING).
+//
+
 function jappixmini_addon_xor(str1, str2) {
     if (str1.length != str2.length) throw "not same length";
 
@@ -162,17 +168,21 @@ function jappixmini_manage_roster(contacts, contacts_hash, autoapprove, autosubs
                        // ignore accounts that are not in the list
                        if (contacts[xid]===undefined) return;
 
-                       // add to Friendica group if necessary
+                       // add to Friendica group or change name if necessary
                        var groups = [];
+                       var group_missing = false;
                        node.find('group').each(function() {
                                var group_text = $(this).text();
                                if (group_text) groups.push(group_text);
                        });
-
                        if ($.inArray("Friendica", groups)==-1) {
+                               group_missing = true;
                                groups.push("Friendica");
-                               sendRoster(xid, null, null, groups);
-                               console.log("Added "+xid+" to Friendica group.");
+                       }
+
+                       if (group_missing || name!=contacts[xid]) {
+                               sendRoster(xid, null, contacts[xid], groups);
+                               console.log("Added "+xid+" to Friendica group and set name to "+contacts[xid]+".");
                        }
 
                        // authorize if necessary