Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1670:3690b4d4157e | 1671:1895846fc9cb |
---|---|
129 # host.bridge.addMethod("subscribeGroupBlog", ".plugin", in_sign='ss', out_sign='', | 129 # host.bridge.addMethod("subscribeGroupBlog", ".plugin", in_sign='ss', out_sign='', |
130 # method=self.subscribeGroupBlog, | 130 # method=self.subscribeGroupBlog, |
131 # async=True) | 131 # async=True) |
132 | 132 |
133 # host.trigger.add("PubSubItemsReceived", self.pubSubItemsReceivedTrigger) | 133 # host.trigger.add("PubSubItemsReceived", self.pubSubItemsReceivedTrigger) |
134 host.trigger.add("XEP-0277_item2data", self._item2dataTrigger) | |
134 host.trigger.add("XEP-0277_data2entry", self._data2entryTrigger) | 135 host.trigger.add("XEP-0277_data2entry", self._data2entryTrigger) |
135 host.trigger.add("XEP-0277_comments", self._commentsTrigger) | 136 host.trigger.add("XEP-0277_comments", self._commentsTrigger) |
136 | 137 |
137 ## plugin management methods ## | 138 ## plugin management methods ## |
138 | 139 |
162 if self.host.isConnected(profile): | 163 if self.host.isConnected(profile): |
163 log.debug("Profile is not connected, service is not checked yet") | 164 log.debug("Profile is not connected, service is not checked yet") |
164 else: | 165 else: |
165 log.error("Service should be available !") | 166 log.error("Service should be available !") |
166 return {} | 167 return {} |
168 | |
169 def _item2dataTrigger(self, item_elt, entry_elt, microblog_data): | |
170 """Parse item to find group permission elements""" | |
171 config_form = data_form.findForm(item_elt, NS_PUBSUB_ITEM_CONFIG) | |
172 if config_form is None: | |
173 return | |
174 access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) | |
175 if access_model == self._p.ACCESS_ROSTER: | |
176 common.iter2dict('group', config_form.fields[self._p.OPT_ROSTER_GROUPS_ALLOWED].values, microblog_data) | |
167 | 177 |
168 def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt): | 178 def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt): |
169 """Build fine access permission if needed | 179 """Build fine access permission if needed |
170 | 180 |
171 This trigger check if "group*" key are present, | 181 This trigger check if "group*" key are present, |