comparison src/plugins/plugin_xep_0277.py @ 916:1a759096ccbd

core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:27:09 +0100
parents 64ec04991d9d
children 301b342c697a
comparison
equal deleted inserted replaced
915:6f96ee4d8cc0 916:1a759096ccbd
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C
21 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
22 from twisted.words.protocols.jabber import jid 23 from twisted.words.protocols.jabber import jid
23 from twisted.internet import defer 24 from twisted.internet import defer
24 from sat.core import exceptions 25 from sat.core import exceptions
25 from sat.tools.xml_tools import ElementParser 26 from sat.tools.xml_tools import ElementParser
307 raise exceptions.DataError('empty content') 308 raise exceptions.DataError('empty content')
308 item = yield self.data2entry(data, profile) 309 item = yield self.data2entry(data, profile)
309 ret = yield self.host.plugins["XEP-0060"].publish(None, NS_MICROBLOG, [item], profile_key=profile) 310 ret = yield self.host.plugins["XEP-0060"].publish(None, NS_MICROBLOG, [item], profile_key=profile)
310 defer.returnValue(ret) 311 defer.returnValue(ret)
311 312
312 def getLastMicroblogs(self, pub_jid, max_items=10, profile_key='@DEFAULT@'): 313 def getLastMicroblogs(self, pub_jid, max_items=10, profile_key=C.PROF_KEY_NONE):
313 """Get the last published microblogs 314 """Get the last published microblogs
314 @param pub_jid: jid of the publisher 315 @param pub_jid: jid of the publisher
315 @param max_items: how many microblogs we want to get 316 @param max_items: how many microblogs we want to get
316 @param profile_key: profile key 317 @param profile_key: profile key
317 """ 318 """
327 d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key) 328 d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key)
328 d.addCallback(lambda items: defer.DeferredList(map(self.item2mbdata, items))) 329 d.addCallback(lambda items: defer.DeferredList(map(self.item2mbdata, items)))
329 d.addCallback(resultToArray) 330 d.addCallback(resultToArray)
330 return d 331 return d
331 332
332 def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@'): 333 def setMicroblogAccess(self, access="presence", profile_key=C.PROF_KEY_NONE):
333 """Create a microblog node on PEP with given access 334 """Create a microblog node on PEP with given access
334 If the node already exists, it change options 335 If the node already exists, it change options
335 @param access: Node access model, according to xep-0060 #4.5 336 @param access: Node access model, according to xep-0060 #4.5
336 @param profile_key: profile key""" 337 @param profile_key: profile key"""
337 338