comparison src/plugins/plugin_xep_0277.py @ 1681:c6c835046681

plugin XEP-0277: minor fixes for publisher attribute
author Goffi <goffi@goffi.org>
date Wed, 25 Nov 2015 18:24:34 +0100
parents 1e06a0f8be66
children a72f04c67ac9
comparison
equal deleted inserted replaced
1680:1e06a0f8be66 1681:c6c835046681
269 title = link_elt.getAttribute('title','') 269 title = link_elt.getAttribute('title','')
270 href = link_elt.getAttribute('href','') 270 href = link_elt.getAttribute('href','')
271 log.warning(u"Unmanaged link element: rel={rel} title={title} href={href}".format(rel=rel, title=title, href=href)) 271 log.warning(u"Unmanaged link element: rel={rel} title={title} href={href}".format(rel=rel, title=title, href=href))
272 272
273 # author 273 # author
274 publisher = item_elt.getAttribute("publisher")
275 try: 274 try:
276 author_elt = entry_elt.elements(NS_ATOM, 'author').next() 275 author_elt = entry_elt.elements(NS_ATOM, 'author').next()
277 except StopIteration: 276 except StopIteration:
278 log.debug(u"Can't find author element in item {}".format(id_)) 277 log.debug(u"Can't find author element in item {}".format(id_))
279 else: 278 else:
279 publisher = item_elt.getAttribute("publisher")
280 # name 280 # name
281 try: 281 try:
282 name_elt = author_elt.elements(NS_ATOM, 'name').next() 282 name_elt = author_elt.elements(NS_ATOM, 'name').next()
283 except StopIteration: 283 except StopIteration:
284 log.warning(u"No name element found in author element of item {}".format(id_)) 284 log.warning(u"No name element found in author element of item {}".format(id_))
300 microblog_data['author_jid'] = item_elt.getAttribute("publisher") or "" 300 microblog_data['author_jid'] = item_elt.getAttribute("publisher") or ""
301 301
302 if not publisher: 302 if not publisher:
303 log.debug(u"No publisher attribute, we can't verify author jid") 303 log.debug(u"No publisher attribute, we can't verify author jid")
304 microblog_data['author_jid_verified'] = C.BOOL_FALSE 304 microblog_data['author_jid_verified'] = C.BOOL_FALSE
305 elif publisher.split("/")[0] == uri.split("/")[0]: 305 elif jid.JID(publisher).userhostJID() == jid.JID(uri).userhostJID():
306 microblog_data['author_jid_verified'] = C.BOOL_TRUE 306 microblog_data['author_jid_verified'] = C.BOOL_TRUE
307 else: 307 else:
308 log.warning(u"item atom:uri differ from publisher attribute, spoofing attempt ? atom:uri = {} publisher = {}".format(uri, item_elt.getAttribute("publisher"))) 308 log.warning(u"item atom:uri differ from publisher attribute, spoofing attempt ? atom:uri = {} publisher = {}".format(uri, item_elt.getAttribute("publisher")))
309 microblog_data['author_jid_verified'] = C.BOOL_FALSE 309 microblog_data['author_jid_verified'] = C.BOOL_FALSE
310 # email 310 # email