Mercurial > libervia-backend
diff src/plugins/plugin_misc_groupblog.py @ 1671:1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 25 Nov 2015 10:45:22 +0100 |
parents | 5d0ff155be1a |
children | dbd7c79aab2b |
line wrap: on
line diff
--- 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