# HG changeset patch # User Goffi # Date 1448444722 -3600 # Node ID 1895846fc9cb79fe2e042b87cdfe6538603d4ccc # Parent 3690b4d4157e3b14864fabe827ddb820cba5869a plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item diff -r 3690b4d4157e -r 1895846fc9cb src/plugins/plugin_misc_groupblog.py --- a/src/plugins/plugin_misc_groupblog.py Wed Nov 25 02:06:44 2015 +0100 +++ b/src/plugins/plugin_misc_groupblog.py Wed Nov 25 10:45:22 2015 +0100 @@ -131,6 +131,7 @@ # async=True) # host.trigger.add("PubSubItemsReceived", self.pubSubItemsReceivedTrigger) + host.trigger.add("XEP-0277_item2data", self._item2dataTrigger) host.trigger.add("XEP-0277_data2entry", self._data2entryTrigger) host.trigger.add("XEP-0277_comments", self._commentsTrigger) @@ -165,6 +166,15 @@ log.error("Service should be available !") return {} + def _item2dataTrigger(self, item_elt, entry_elt, microblog_data): + """Parse item to find group permission elements""" + config_form = data_form.findForm(item_elt, NS_PUBSUB_ITEM_CONFIG) + if config_form is None: + return + access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) + if access_model == self._p.ACCESS_ROSTER: + common.iter2dict('group', config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values, microblog_data) + def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt): """Build fine access permission if needed diff -r 3690b4d4157e -r 1895846fc9cb src/plugins/plugin_xep_0277.py --- a/src/plugins/plugin_xep_0277.py Wed Nov 25 02:06:44 2015 +0100 +++ b/src/plugins/plugin_xep_0277.py Wed Nov 25 10:45:22 2015 +0100 @@ -319,6 +319,10 @@ categories = (category_elt.getAttribute('term','') for category_elt in entry_elt.elements(NS_ATOM, 'category')) common.iter2dict('tag', categories, microblog_data) + ## the trigger ## + # if other plugins have things to add or change + yield self.host.trigger.point("XEP-0277_item2data", item_elt, entry_elt, microblog_data) + defer.returnValue(microblog_data) @defer.inlineCallbacks