matridge.contact¶
Classes¶
Module Contents¶
- class matridge.contact.Contact(session, legacy_id, jid_username)[source]¶
Bases:
slidge.LegacyContact
[str
]We don’t implement direct messages but the what’s parsed here will propagate to MUC participants.
- Parameters:
session (slidge.core.session.BaseSession) – The session this contact is part of
legacy_id (slidge.util.types.LegacyUserIdType) – The contact’s legacy ID
jid_username (str) – User part of this contact’s ‘puppet’ JID. NB: case-insensitive, and some special characters are not allowed
- session: matridge.session.Session[source]¶
- async update_info()[source]¶
Fetch information about this contact from the legacy network
This is awaited on Contact instantiation, and should be overridden to update the nickname, avatar, vcard […] of this contact, by making “legacy API calls”.
To take advantage of the slidge avatar cache, you can check the .avatar property to retrieve the “legacy file ID” of the cached avatar. If there is no change, you should not call
slidge.core.mixins.avatar.AvatarMixin.set_avatar()
or attempt to modify the.avatar
property.
- class matridge.contact.Roster(session)[source]¶
Bases:
slidge.LegacyRoster
[str
,Contact
]Virtual roster of a gateway user, that allows to represent all of their contacts as singleton instances (if used properly and not too bugged).
Every
BaseSession
instance will have its ownLegacyRoster
instance accessible via theBaseSession.contacts
attribute.Typically, you will mostly use the
LegacyRoster.by_legacy_id()
function to retrieve a contact instance.You might need to override
LegacyRoster.legacy_id_to_jid_username()
and/orLegacyRoster.jid_username_to_legacy_id()
to incorporate some custom logic if you need some characters when translation JID user parts and legacy IDs.- Parameters:
session (slidge.core.session.BaseSession)
- session: matridge.session.Session[source]¶
- async jid_username_to_legacy_id(jid_username)[source]¶
Convert a JID user part to a legacy ID.
Should be overridden in case legacy IDs are not strings, or more generally for any case where the username part of a JID (unescaped with to the mapping defined by XEP-0106) is not enough to identify a contact on the legacy network.
Default implementation is an identity operation
- Parameters:
jid_username (str) – User part of a JID, ie “user” in “user@example.com”
- Returns:
An identifier for the user on the legacy network.