| ... |
... |
@@ -36,6 +36,8 @@ |
|
36
|
36
|
from gajim.common.const import ClientState
|
|
37
|
37
|
from gajim.common.structs import OutgoingMessage
|
|
38
|
38
|
from gajim.common.modules.base import BaseModule
|
|
|
39
|
+from gajim.common.modules.contacts import GroupchatParticipant
|
|
|
40
|
+from gajim.common.modules.contacts import BareContact
|
|
39
|
41
|
|
|
40
|
42
|
INACTIVE_AFTER = 60
|
|
41
|
43
|
PAUSED_AFTER = 10
|
| ... |
... |
@@ -270,9 +272,9 @@ def set_chatstate(self, contact: types.ChatContactT, state: State) -> None: |
|
270
|
272
|
if setting == 'disabled':
|
|
271
|
273
|
# Send a last 'active' state after user disabled chatstates
|
|
272
|
274
|
if current_state is not None:
|
|
273
|
|
- self._log.info('Disabled for %s', contact.jid)
|
|
|
275
|
+ self._log.info('Disabled for %s', contact)
|
|
274
|
276
|
self._log.info('Send last state: %-10s - %s',
|
|
275
|
|
- State.ACTIVE, contact.jid)
|
|
|
277
|
+ State.ACTIVE, contact)
|
|
276
|
278
|
|
|
277
|
279
|
self._send_chatstate(contact, State.ACTIVE)
|
|
278
|
280
|
|
| ... |
... |
@@ -281,22 +283,23 @@ def set_chatstate(self, contact: types.ChatContactT, state: State) -> None: |
|
281
|
283
|
self._last_keyboard_activity.pop(contact.jid, None)
|
|
282
|
284
|
return
|
|
283
|
285
|
|
|
284
|
|
- if not contact.is_groupchat:
|
|
285
|
|
- # Don’t leak presence to contacts
|
|
286
|
|
- # which are not allowed to see our status
|
|
287
|
|
- if not contact.is_pm_contact:
|
|
288
|
|
- # TODO
|
|
289
|
|
- # if contact and contact.sub in ('to', 'none'):
|
|
290
|
|
- # self._log.info('Contact not subscribed: %s', contact.jid)
|
|
291
|
|
- # return
|
|
292
|
|
- pass
|
|
|
286
|
+ if isinstance(contact, BareContact):
|
|
|
287
|
+ if not contact.is_subscribed:
|
|
|
288
|
+ self._log.debug('Contact not subscribed: %s', contact)
|
|
|
289
|
+ return
|
|
293
|
290
|
|
|
294
|
291
|
if not contact.is_available:
|
|
295
|
|
- self._log.info('Contact offline: %s', contact.jid)
|
|
|
292
|
+ self._log.debug('Contact offline: %s', contact)
|
|
296
|
293
|
return
|
|
297
|
294
|
|
|
298
|
|
- if not contact.supports(Namespace.CHATSTATES):
|
|
299
|
|
- self._log.info('Chatstates not supported: %s', contact.jid)
|
|
|
295
|
+ elif isinstance(contact, GroupchatParticipant):
|
|
|
296
|
+ if not contact.is_available:
|
|
|
297
|
+ self._log.debug('Contact offline: %s', contact)
|
|
|
298
|
+ return
|
|
|
299
|
+
|
|
|
300
|
+ else:
|
|
|
301
|
+ if not contact.is_joined:
|
|
|
302
|
+ self._log.debug('Groupchat not joined: %s', contact)
|
|
300
|
303
|
return
|
|
301
|
304
|
|
|
302
|
305
|
if state in (State.ACTIVE, State.COMPOSING):
|
| ... |
... |
@@ -309,7 +312,7 @@ def set_chatstate(self, contact: types.ChatContactT, state: State) -> None: |
|
309
|
312
|
if current_state == state:
|
|
310
|
313
|
return
|
|
311
|
314
|
|
|
312
|
|
- self._log.info('Send: %-10s - %s', state, contact.jid)
|
|
|
315
|
+ self._log.info('Send: %-10s - %s', state, contact)
|
|
313
|
316
|
|
|
314
|
317
|
self._send_chatstate(contact, state)
|
|
315
|
318
|
|