Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
58bb2d25
by Philipp Hörist at 2019-12-14T09:52:53Z
3 changed files:
Changes:
| ... | ... | @@ -279,7 +279,6 @@ class Presence(BaseModule): |
| 279 | 279 |
|
| 280 | 280 |
def _subscribed_received(self, _con, _stanza, properties):
|
| 281 | 281 |
jid = properties.jid.getBare()
|
| 282 |
- resource = properties.jid.getResource()
|
|
| 283 | 282 |
self._log.info('Received Subscribed: %s', properties.jid)
|
| 284 | 283 |
if jid in self.automatically_added:
|
| 285 | 284 |
self.automatically_added.remove(jid)
|
| ... | ... | @@ -287,7 +286,8 @@ class Presence(BaseModule): |
| 287 | 286 |
|
| 288 | 287 |
app.nec.push_incoming_event(NetworkEvent(
|
| 289 | 288 |
'subscribed-presence-received',
|
| 290 |
- conn=self._con, jid=jid, resource=resource))
|
|
| 289 |
+ account=self._account,
|
|
| 290 |
+ jid=properties.jid))
|
|
| 291 | 291 |
raise nbxmpp.NodeProcessed
|
| 292 | 292 |
|
| 293 | 293 |
def _unsubscribe_received(self, _con, _stanza, properties):
|
| ... | ... | @@ -320,25 +320,39 @@ class Interface: |
| 320 | 320 |
event_type, obj.jid, account, 'subscription_request',
|
| 321 | 321 |
'gajim-subscription_request', event_type, obj.jid)
|
| 322 | 322 |
|
| 323 |
- def handle_event_subscribed_presence(self, obj):
|
|
| 324 |
- #('SUBSCRIBED', account, (jid, resource))
|
|
| 325 |
- account = obj.conn.name
|
|
| 326 |
- if obj.jid in app.contacts.get_jid_list(account):
|
|
| 327 |
- c = app.contacts.get_first_contact_from_jid(account, obj.jid)
|
|
| 328 |
- c.resource = obj.resource
|
|
| 329 |
- self.roster.remove_contact_from_groups(c.jid, account,
|
|
| 330 |
- [_('Not in contact list'), _('Observers')], update=False)
|
|
| 323 |
+ def handle_event_subscribed_presence(self, event):
|
|
| 324 |
+ bare_jid = event.jid.getBare()
|
|
| 325 |
+ resource = event.jid.getResource()
|
|
| 326 |
+ if bare_jid in app.contacts.get_jid_list(event.account):
|
|
| 327 |
+ contact = app.contacts.get_first_contact_from_jid(event.account,
|
|
| 328 |
+ bare_jid)
|
|
| 329 |
+ contact.resource = resource
|
|
| 330 |
+ self.roster.remove_contact_from_groups(contact.jid,
|
|
| 331 |
+ event.account,
|
|
| 332 |
+ [_('Not in contact list'),
|
|
| 333 |
+ _('Observers')],
|
|
| 334 |
+ update=False)
|
|
| 331 | 335 |
else:
|
| 332 |
- name = obj.jid.split('@', 1)[0]
|
|
| 336 |
+ name = event.jid.getNode()
|
|
| 333 | 337 |
name = name.split('%', 1)[0]
|
| 334 |
- contact1 = app.contacts.create_contact(jid=obj.jid,
|
|
| 335 |
- account=account, name=name, groups=[], show='online',
|
|
| 336 |
- status='online', ask='to', resource=obj.resource)
|
|
| 337 |
- app.contacts.add_contact(account, contact1)
|
|
| 338 |
- self.roster.add_contact(obj.jid, account)
|
|
| 339 |
- InformationDialog(_('Authorization accepted'),
|
|
| 340 |
- _('The contact "%s" has authorized you to see their status.')
|
|
| 341 |
- % obj.jid)
|
|
| 338 |
+ contact = app.contacts.create_contact(jid=bare_jid,
|
|
| 339 |
+ account=event.account,
|
|
| 340 |
+ name=name,
|
|
| 341 |
+ groups=[],
|
|
| 342 |
+ show='online',
|
|
| 343 |
+ status='online',
|
|
| 344 |
+ ask='to',
|
|
| 345 |
+ resource=resource)
|
|
| 346 |
+ app.contacts.add_contact(event.account, contact)
|
|
| 347 |
+ self.roster.add_contact(bare_jid, event.account)
|
|
| 348 |
+ |
|
| 349 |
+ app.notification.popup(
|
|
| 350 |
+ None,
|
|
| 351 |
+ bare_jid,
|
|
| 352 |
+ event.account,
|
|
| 353 |
+ title=_('Authorization accepted'),
|
|
| 354 |
+ text=_('The contact "%s" has authorized you'
|
|
| 355 |
+ ' to see their status.') % event.jid)
|
|
| 342 | 356 |
|
| 343 | 357 |
def show_unsubscribed_dialog(self, account, contact):
|
| 344 | 358 |
def _remove():
|
| ... | ... | @@ -357,9 +357,10 @@ class GajimRemote(Server): |
| 357 | 357 |
self.raise_signal('Subscribe', (obj.conn.name, [obj.jid, obj.status,
|
| 358 | 358 |
obj.user_nick]))
|
| 359 | 359 |
|
| 360 |
- def on_subscribed_presence_received(self, obj):
|
|
| 361 |
- self.raise_signal('Subscribed', (obj.conn.name, [obj.jid,
|
|
| 362 |
- obj.resource]))
|
|
| 360 |
+ def on_subscribed_presence_received(self, event):
|
|
| 361 |
+ self.raise_signal('Subscribed', (event.account,
|
|
| 362 |
+ [event.jid.getBare(),
|
|
| 363 |
+ event.jid.getResource()]))
|
|
| 363 | 364 |
|
| 364 | 365 |
def on_unsubscribed_presence_received(self, obj):
|
| 365 | 366 |
self.raise_signal('Unsubscribed', (obj.conn.name, obj.jid))
|