]> git.mxchange.org Git - friendica-addons.git/commitdiff
jappixmini: add to Friendica group and authorize
authorLeberwurscht <leberwurscht@hoegners.de>
Mon, 16 Apr 2012 22:41:22 +0000 (00:41 +0200)
committerLeberwurscht <leberwurscht@hoegners.de>
Mon, 16 Apr 2012 22:41:22 +0000 (00:41 +0200)
jappixmini/lib.js

index dd2d795539a2e7a6f1db43057ba022c139b6fc31..bbbc7e34e008b057baa8879912789c1283985968 100644 (file)
@@ -147,9 +147,24 @@ function jappixmini_manage_roster(contacts, autoapprove, autosubscribe) {
                        // ignore accounts not in the list
                        if (contacts[xid]===undefined) return;
 
-                       // TODO: add to Friendica group
-
-                       // TODO: unblock and authorize if necessary
+                       // add to Friendica group if necessary
+                       groups = [];
+                       $(this).find('group').each(function() {
+                               var group_text = $(this).text();
+                               if(group_text) groups.push(group_text);
+                       });
+
+                       if ($.inArray("Friendica", groups)==-1) {
+                               console.log("Add "+xid+" to Friendica group.");
+                               groups.push("Friendica");
+                               sendRoster(xid, null, null, groups);
+                               console.log("Added "+xid+" to Friendica group.");
+                       }
+
+                       // authorize if necessary
+                       if (subscription=="to") {
+                               sendSubscribe(xid, 'subscribed');
+                       }
 
                        // remove from list
                        delete contacts[xid];