Mercurial > libervia-backend
annotate src/plugins/plugin_misc_groupblog.py @ 519:b7577230a7c8
reverted bad commit
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Oct 2012 12:55:27 +0200 |
parents | 2a072735e459 |
children | c18e0e108925 |
rev | line source |
---|---|
307 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SAT plugin for microbloging with roster access | |
459 | 6 Copyright (C) 2009, 2010, 2011, 2012 Jérôme Poisson (goffi@goffi.org) |
307 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
478
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
307 | 10 the Free Software Foundation, either version 3 of the License, or |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
478
diff
changeset
|
16 GNU Affero General Public License for more details. |
307 | 17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
478
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
307 | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | |
21 | |
22 from logging import debug, info, error | |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
23 from twisted.internet import defer |
307 | 24 from twisted.words.protocols.jabber import jid |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
25 |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
26 from wokkel import disco, data_form, iwokkel |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
27 |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
28 from zope.interface import implements |
307 | 29 |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
30 try: |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
31 from twisted.words.protocols.xmlstream import XMPPHandler |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
32 except ImportError: |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
33 from wokkel.subprotocols import XMPPHandler |
307 | 34 |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
35 NS_PUBSUB = 'http://jabber.org/protocol/pubsub' |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
36 NS_GROUPBLOG = 'http://goffi.org/protocol/groupblog' |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
37 NS_NODE_PREFIX = 'urn:xmpp:groupblog:' |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
38 #NS_PUBSUB_EXP = 'http://goffi.org/protocol/pubsub' #for non official features |
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
39 NS_PUBSUB_EXP = NS_PUBSUB #XXX: we can't use custom namespace as Wokkel's PubSubService use official NS |
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
40 NS_PUBSUB_ITEM_ACCESS = NS_PUBSUB_EXP + "#item-access" |
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
41 NS_PUBSUB_CREATOR_JID_CHECK = NS_PUBSUB_EXP + "#creator-jid-check" |
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
42 NS_PUBSUB_ITEM_CONFIG = NS_PUBSUB_EXP + "#item-config" |
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
43 NS_PUBSUB_AUTO_CREATE = NS_PUBSUB + "#auto-create" |
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
44 OPT_ROSTER_GROUPS_ALLOWED = 'pubsub#roster_groups_allowed' |
310
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
45 OPT_ACCESS_MODEL = 'pubsub#access_model' |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
46 OPT_PERSIST_ITEMS = 'pubsub#persist_items' |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
47 OPT_MAX_ITEMS = 'pubsub#max_items' |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
48 OPT_NODE_TYPE = 'pubsub#node_type' |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
49 OPT_SUBSCRIPTION_TYPE = 'pubsub#subscription_type' |
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
50 OPT_SUBSCRIPTION_DEPTH = 'pubsub#subscription_depth' |
307 | 51 TYPE_COLLECTION = 'collection' |
52 | |
53 PLUGIN_INFO = { | |
54 "name": "Group blogging throught collections", | |
55 "import_name": "groupblog", | |
56 "type": "MISC", | |
57 "protocols": [], | |
58 "dependencies": ["XEP-0277"], | |
59 "main": "GroupBlog", | |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
60 "handler": "yes", |
307 | 61 "description": _("""Implementation of microblogging with roster access""") |
62 } | |
63 | |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
64 class NoCompatiblePubSubServerFound(Exception): |
308
ce3607b7198d
plugin group blog: blog collection cleaning
Goffi <goffi@goffi.org>
parents:
307
diff
changeset
|
65 pass |
ce3607b7198d
plugin group blog: blog collection cleaning
Goffi <goffi@goffi.org>
parents:
307
diff
changeset
|
66 |
471 | 67 class BadAccessTypeError(Exception): |
68 pass | |
69 | |
70 class BadAccessListError(Exception): | |
71 pass | |
72 | |
307 | 73 class GroupBlog(): |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
74 """This class use a SàT PubSub Service to manage access on microblog""" |
307 | 75 |
76 def __init__(self, host): | |
77 info(_("Group blog plugin initialization")) | |
78 self.host = host | |
79 | |
471 | 80 host.bridge.addMethod("sendGroupBlog", ".plugin", in_sign='sasss', out_sign='', |
81 method=self.sendGroupBlog) | |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
82 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
83 host.bridge.addMethod("getLastGroupBlogs", ".plugin", |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
84 in_sign='sis', out_sign='aa{ss}', |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
85 method=self.getLastGroupBlogs, |
471 | 86 async = True) |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
87 |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
88 host.bridge.addMethod("getMassiveLastGroupBlogs", ".plugin", |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
89 in_sign='sasis', out_sign='a{saa{ss}}', |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
90 method=self.getMassiveLastGroupBlogs, |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
91 async = True) |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
92 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
93 host.bridge.addMethod("subscribeGroupBlog", ".plugin", in_sign='ss', out_sign='', |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
94 method=self.subscribeGroupBlog, |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
95 async = True) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
96 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
97 host.bridge.addMethod("massiveSubscribeGroupBlogs", ".plugin", in_sign='sass', out_sign='', |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
98 method=self.massiveSubscribeGroupBlogs, |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
99 async = True) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
100 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
101 host.trigger.add("PubSubItemsReceived", self.pubSubItemsReceivedTrigger) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
102 |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
103 |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
104 def getHandler(self, profile): |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
105 return GroupBlog_handler() |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
106 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
107 @defer.inlineCallbacks |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
108 def initialise(self, profile_key): |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
109 """Check that this data for this profile are initialised, and do it else |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
110 @param client: client of the profile |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
111 @profile_key: %(doc_profile)s""" |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
112 profile = self.host.memory.getProfileName(profile_key) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
113 if not profile: |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
114 error(_("Unknown profile")) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
115 raise Exception("Unknown profile") |
310
53adec87d1d7
plugin group blog: group blog subscription
Goffi <goffi@goffi.org>
parents:
308
diff
changeset
|
116 |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
117 client = self.host.getClient(profile) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
118 if not client: |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
119 error(_('No client for this profile key: %s') % profile_key) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
120 raise Exception("Unknown profile") |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
121 yield client.client_initialized #we want to be sure that the client is initialized |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
122 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
123 #we first check that we have a item-access pubsub server |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
124 if not hasattr(client,"item_access_pubsub"): |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
125 debug(_('Looking for item-access power pubsub server')) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
126 #we don't have any pubsub server featuring item access yet |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
127 client.item_access_pubsub = None |
478
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
128 client._item_access_pubsub_pending = defer.Deferred() |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
129 for entity in self.host.memory.getServerServiceEntities("pubsub", "service", profile): |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
130 _disco = yield client.disco.requestInfo(entity) |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
131 #if set([NS_PUBSUB_ITEM_ACCESS, NS_PUBSUB_AUTO_CREATE, NS_PUBSUB_CREATOR_JID_CHECK]).issubset(_disco.features): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
132 if set([NS_PUBSUB_AUTO_CREATE, NS_PUBSUB_CREATOR_JID_CHECK]).issubset(_disco.features): |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
133 info(_("item-access powered pubsub service found: [%s]") % entity.full()) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
134 client.item_access_pubsub = entity |
478
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
135 client._item_access_pubsub_pending.callback(None) |
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
136 |
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
137 if hasattr(client,"_item_access_pubsub_pending"): |
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
138 #XXX: we need to wait for item access pubsub service check |
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
139 ignore = yield client._item_access_pubsub_pending |
f856575a62a6
plugin groupblog: fixed initialisation
Goffi <goffi@goffi.org>
parents:
477
diff
changeset
|
140 del client._item_access_pubsub_pending |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
141 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
142 if not client.item_access_pubsub: |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
143 error(_("No item-access powered pubsub server found, can't use group blog")) |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
144 raise NoCompatiblePubSubServerFound |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
145 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
146 defer.returnValue((profile, client)) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
147 |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
148 def pubSubItemsReceivedTrigger(self, event, profile): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
149 """"Trigger which catch groupblogs events""" |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
150 if event.nodeIdentifier.startswith(NS_NODE_PREFIX): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
151 for item in event.items: |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
152 microblog_data = self.host.plugins["XEP-0277"].item2mbdata(item) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
153 self.host.bridge.personalEvent(event.sender.full(), "MICROBLOG", microblog_data, profile) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
154 return False |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
155 return True |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
156 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
157 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
158 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
159 def getNodeName(self, publisher): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
160 """Retrieve the name of publisher's node |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
161 @param publisher: publisher's jid |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
162 @return: node's name (string)""" |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
163 return NS_NODE_PREFIX + publisher.userhost() |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
164 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
165 |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
166 |
471 | 167 def _publishMblog(self, service, client, access_type, access_list, message): |
307 | 168 """Actually publish the message on the group blog |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
169 @param service: jid of the item-access pubsub service |
471 | 170 @param client: SatXMPPClient of the published |
171 @param access_type: one of "PUBLIC", "GROUP", "JID" | |
172 @param access_list: set of entities (empty list for all, groups or jids) allowed to see the item | |
307 | 173 @param message: message to publish |
471 | 174 """ |
311
0aa6ca6cdbdd
plugin group blog: group blog now use PEP to take profit of autosubscribe
Goffi <goffi@goffi.org>
parents:
310
diff
changeset
|
175 mblog_item = self.host.plugins["XEP-0277"].data2entry({'content':message}, client.profile) |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
176 form = data_form.Form('submit', formNamespace=NS_PUBSUB_ITEM_CONFIG) |
471 | 177 if access_type == "PUBLIC": |
178 if access_list: | |
179 raise BadAccessListError("access_list must be empty for PUBLIC access") | |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
180 access = data_form.Field(None, OPT_ACCESS_MODEL, value="open") |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
181 form.addField(access) |
471 | 182 elif access_type == "GROUP": |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
183 access = data_form.Field(None, OPT_ACCESS_MODEL, value="roster") |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
184 allowed = data_form.Field(None, OPT_ROSTER_GROUPS_ALLOWED, values=access_list) |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
185 form.addField(access) |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
186 form.addField(allowed) |
471 | 187 mblog_item.addChild(form.toElement()) |
188 elif access_type == "JID": | |
189 raise NotImplementedError | |
190 else: | |
191 error(_("Unknown access_type")) | |
192 raise BadAccessTypeError | |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
193 defer_blog = self.host.plugins["XEP-0060"].publish(service, self.getNodeName(client.jid), items=[mblog_item], profile_key=client.profile) |
307 | 194 defer_blog.addErrback(self._mblogPublicationFailed) |
195 | |
196 def _mblogPublicationFailed(self, failure): | |
197 #TODO | |
471 | 198 return failure |
307 | 199 |
471 | 200 def sendGroupBlog(self, access_type, access_list, message, profile_key='@DEFAULT@'): |
201 """Publish a microblog with given item access | |
202 @param access_type: one of "PUBLIC", "GROUP", "JID" | |
203 @param access_list: list of authorized entity (empty list for PUBLIC ACCESS, | |
204 list of groups or list of jids) for this item | |
307 | 205 @param message: microblog |
206 @profile_key: %(doc_profile)s | |
207 """ | |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
208 print "sendGroupBlog" |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
209 def initialised(result): |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
210 profile, client = result |
471 | 211 if access_type == "PUBLIC": |
212 if access_list: | |
213 raise Exception("Publishers list must be empty when getting microblogs for all contacts") | |
214 self._publishMblog(client.item_access_pubsub, client, "PUBLIC", [], message) | |
215 elif access_type == "GROUP": | |
216 _groups = set(access_list).intersection(client.roster.getGroups()) #We only keep group which actually exist | |
217 if not _groups: | |
218 raise BadAccessListError("No valid group") | |
219 self._publishMblog(client.item_access_pubsub, client, "GROUP", _groups, message) | |
220 elif access_type == "JID": | |
221 raise NotImplementedError | |
222 else: | |
223 error(_("Unknown access type")) | |
224 raise BadAccessTypeError | |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
225 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
226 self.initialise(profile_key).addCallback(initialised) |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
227 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
228 |
308
ce3607b7198d
plugin group blog: blog collection cleaning
Goffi <goffi@goffi.org>
parents:
307
diff
changeset
|
229 |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
230 def getLastGroupBlogs(self, pub_jid, max_items=10, profile_key='@DEFAULT@'): |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
231 """Get the last published microblogs |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
232 @param pub_jid: jid of the publisher |
471 | 233 @param max_items: how many microblogs we want to get (see XEP-0060 #6.5.7) |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
234 @param profile_key: profile key |
471 | 235 @return: list of microblog data (dict) |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
236 """ |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
237 |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
238 def initialised(result): |
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
239 profile, client = result |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
240 d = self.host.plugins["XEP-0060"].getItems(client.item_access_pubsub, self.getNodeName(jid.JID(pub_jid)), |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
241 max_items=max_items, profile_key=profile_key) |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
242 d.addCallback(lambda items: map(self.host.plugins["XEP-0277"].item2mbdata, items)) |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
243 d.addErrback(lambda ignore: {}) #TODO: more complete error management (log !) |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
244 return d |
308
ce3607b7198d
plugin group blog: blog collection cleaning
Goffi <goffi@goffi.org>
parents:
307
diff
changeset
|
245 |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
246 #TODO: we need to use the server corresponding the the host of the jid |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
247 return self.initialise(profile_key).addCallback(initialised) |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
248 |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
249 def getMassiveLastGroupBlogs(self, publishers_type, publishers, max_items=10, profile_key='@DEFAULT@'): |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
250 """Get the last published microblogs for a list of groups or jids |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
251 @param publishers_type: type of the list of publishers (one of "GROUP" or "JID" or "ALL") |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
252 @param publishers: list of publishers, according to "publishers_type" (list of groups or list of jids) |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
253 @param max_items: how many microblogs we want to get |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
254 @param profile_key: profile key |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
255 """ |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
256 def sendResult(result): |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
257 """send result of DeferredList (list of microblogs to the calling method""" |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
258 |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
259 ret = {} |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
260 |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
261 for (success, value) in result: |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
262 if success: |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
263 source_jid, data = value |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
264 ret[source_jid] = data |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
265 |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
266 return ret |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
267 |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
268 def initialised(result): |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
269 profile, client = result |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
270 |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
271 if publishers_type == "ALL": |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
272 contacts = client.roster.getItems() |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
273 jids = [contact.jid.userhost() for contact in contacts] |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
274 mblogs = [] |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
275 for _jid in jids: |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
276 d = self.host.plugins["XEP-0060"].getItems(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)), |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
277 max_items=max_items, profile_key=profile_key) |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
278 d.addCallback(lambda items, source_jid: (source_jid, map(self.host.plugins["XEP-0277"].item2mbdata, items)), _jid) |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
279 mblogs.append(d) |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
280 dlist = defer.DeferredList(mblogs) |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
281 dlist.addCallback(sendResult) |
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
282 return dlist |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
283 |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
284 return defer.fail("Unknown type") |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
285 |
470
5c916b99d0f6
plugin groupblog, D-Bus frontend: added getLastGroupBlogs and getMassiveLastGroupBlogs
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
286 |
467
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
287 #TODO: custom exception |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
288 if publishers_type not in ["GROUP", "JID", "ALL"]: |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
289 raise Exception("Bad call, unknown publishers_type") |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
290 if publishers_type=="ALL" and publishers: |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
291 raise Exception("Publishers list must be empty when getting microblogs for all contacts") |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
292 return self.initialise(profile_key).addCallback(initialised) |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
293 #TODO: we need to use the server corresponding the the host of the jid |
47af60767013
plugin group blog: getMassiveGroupBlog first draft
Goffi <goffi@goffi.org>
parents:
465
diff
changeset
|
294 |
477
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
295 def subscribeGroupBlog(self, pub_jid, profile_key='@DEFAULT'): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
296 def initialised(result): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
297 profile, client = result |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
298 d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid.JID(pub_jid)), |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
299 profile_key=profile_key) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
300 return d |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
301 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
302 #TODO: we need to use the server corresponding the the host of the jid |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
303 return self.initialise(profile_key).addCallback(initialised) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
304 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
305 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
306 def massiveSubscribeGroupBlogs(self, publishers_type, publishers, profile_key='@DEFAULT@'): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
307 """Subscribe microblogs for a list of groups or jids |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
308 @param publishers_type: type of the list of publishers (one of "GROUP" or "JID" or "ALL") |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
309 @param publishers: list of publishers, according to "publishers_type" (list of groups or list of jids) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
310 @param profile_key: profile key |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
311 """ |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
312 def initialised(result): |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
313 profile, client = result |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
314 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
315 if publishers_type == "ALL": |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
316 contacts = client.roster.getItems() |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
317 jids = [contact.jid.userhost() for contact in contacts] |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
318 mblogs = [] |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
319 for _jid in jids: |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
320 d = self.host.plugins["XEP-0060"].subscribe(client.item_access_pubsub, self.getNodeName(jid.JID(_jid)), |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
321 profile_key=profile_key) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
322 mblogs.append(d) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
323 dlist = defer.DeferredList(mblogs) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
324 return dlist |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
325 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
326 return defer.fail("Unknown type") |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
327 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
328 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
329 #TODO: custom exception |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
330 if publishers_type not in ["GROUP", "JID", "ALL"]: |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
331 raise Exception("Bad call, unknown publishers_type") |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
332 if publishers_type=="ALL" and publishers: |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
333 raise Exception("Publishers list must be empty when getting microblogs for all contacts") |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
334 return self.initialise(profile_key).addCallback(initialised) |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
335 #TODO: we need to use the server corresponding the the host of the jid |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
336 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
337 |
031b0e0aaab8
plugin groupblog: subscriptions/notifications
Goffi <goffi@goffi.org>
parents:
476
diff
changeset
|
338 |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
339 class GroupBlog_handler(XMPPHandler): |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
340 implements(iwokkel.IDisco) |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
341 |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
342 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
343 return [disco.DiscoFeature(NS_GROUPBLOG)] |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
344 |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
345 def getDiscoItems(self, requestor, target, nodeIdentifier=''): |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
346 return [] |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
347 |