Mercurial > libervia-backend
changeset 2941:83cbd4545274
plugin events: fixed invitation + set name and thumb_url from event element
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 04 May 2019 00:06:41 +0200 |
parents | ef554aca3eb1 |
children | 8dbef2d190eb |
files | sat/plugins/plugin_exp_events.py sat/plugins/plugin_exp_invitation.py |
diffstat | 2 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_exp_events.py Sat May 04 00:05:11 2019 +0200 +++ b/sat/plugins/plugin_exp_events.py Sat May 04 00:06:41 2019 +0200 @@ -143,7 +143,7 @@ """Helper method to parse event element @param (domish.Element): event_elt - @return (tupple[int, dict[unicode, unicode]): timestamp, event_data + @return (tuple[int, dict[unicode, unicode]): timestamp, event_data """ try: timestamp = date_utils.date_parse(next(event_elt.elements(NS_EVENT, "date"))) @@ -232,9 +232,9 @@ raise exceptions.NotFound(_(u"No event with this id has been found")) defer.returnValue(event_elt) - def register(self, client, name, extra, service, node, event_id, event_elt, + def register(self, client, name, extra, service, node, event_id, item_elt, creator=False): - """register evenement in personal events list + """Register evenement in personal events list @param service(jid.JID): pubsub service of the event @param node(unicode): event node @@ -243,14 +243,20 @@ note that this element will be modified in place @param creator(bool): True if client's profile is the creator of the node """ - # FIXME: name and extra are unused + event_elt = item_elt.event link_elt = event_elt.addElement("link") link_elt["service"] = service.full() link_elt["node"] = node link_elt["item"] = event_id + __, event_data = self._parseEventElt(event_elt) + name = event_data.get(u'name') + if u'image' in event_data: + extra = {u'thumb_url': event_data[u'image']} + else: + extra = None return self.host.plugins[u'LIST_INTEREST'].registerPubsub( client, NS_EVENT, service, node, event_id, creator, - element=event_elt) + name=name, element=event_elt, extra=extra) def _eventGet(self, service, node, id_=u"", profile_key=C.PROF_KEY_NONE): service = jid.JID(service) if service else None @@ -431,9 +437,10 @@ for item in items: try: event_elt = next(item.interest.pubsub.elements(NS_EVENT, u"event")) - except IndexError: + except StopIteration: log.warning( - _(u"No event found in item {item_id}").format(item_id=item["id"]) + _(u"No event found in item {item_id}, ignoring").format( + item_id=item["id"]) ) else: timestamp, data = self._parseEventElt(event_elt) @@ -595,9 +602,9 @@ log.debug(_(u"affiliation set on blog and comments nodes")) # now we send the invitation - pubsub_invitation = self.host.plugins[u'PUBSUB_INVITATION'] + pubsub_invitation = self.host.plugins[u'INVITATION'] pubsub_invitation.sendPubsubInvitation(client, invitee_jid, service, node, - item_id, name, extra) + item_id, name, extra) def _inviteByEmail(self, service, node, id_=NS_EVENT, email=u"", emails_extra=None, name=u"", host_name=u"", language=u"", url_template=u"",
--- a/sat/plugins/plugin_exp_invitation.py Sat May 04 00:05:11 2019 +0200 +++ b/sat/plugins/plugin_exp_invitation.py Sat May 04 00:06:41 2019 +0200 @@ -125,7 +125,7 @@ return mess_data, invitation_elt def sendPubsubInvitation(self, client, invitee_jid, service, node, - item_id, name, extra): + item_id, name, extra): """Send an pubsub invitation in a <message> stanza @param invitee_jid(jid.JID): entitee to send invitation to