Commit 1657c701 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Use JID objects instead of str

parent 098274e8
......@@ -1414,7 +1414,7 @@ def get_group_chat_nick(account: str, room_jid: Union[JID, str]) -> str:
return nick
def get_muc_context(jid: Union[JID, str]) -> Optional[str]:
def get_muc_context(jid: JID) -> Optional[str]:
disco_info = app.storage.cache.get_last_disco_info(jid)
if disco_info is None:
return None
......
......@@ -106,8 +106,9 @@ def _entity_caps(self, _con, _stanza, properties):
self._queue_task(task)
return
jid = str(properties.jid)
app.storage.cache.set_last_disco_info(jid, disco_info, cache_only=True)
app.storage.cache.set_last_disco_info(properties.jid,
disco_info,
cache_only=True)
contact = self._con.get_module('Contacts').get_contact(properties.jid)
contact.notify('caps-update')
......@@ -145,7 +146,7 @@ def _on_disco_info(self, nbxmpp_task):
return
app.storage.cache.add_caps_entry(
str(disco_info.jid),
disco_info.jid,
task.entity.method,
disco_info.get_caps_hash(),
disco_info)
......
......@@ -103,7 +103,7 @@ def _raise_event(self, name, properties):
def _send_marker(self, contact, marker, id_, type_):
jid = contact.jid
if contact.is_pm_contact:
jid = contact.jid.bare
jid = contact.jid.new_as_bare()
if type_ in ('gc', 'pm'):
if not app.settings.get_group_chat_setting(
......
......@@ -45,13 +45,13 @@
class ContactSettings:
def __init__(self, account: str, jid: str) -> None:
def __init__(self, account: str, jid: JID) -> None:
self.get = partial(app.settings.get_contact_setting, account, jid)
self.set = partial(app.settings.set_contact_setting, account, jid)
class GroupChatSettings:
def __init__(self, account: str, jid: str) -> None:
def __init__(self, account: str, jid: JID) -> None:
self._account = account
self._jid = jid
......@@ -73,7 +73,7 @@ def set(self, setting: BoolGroupChatSettings, value: bool) -> None: ...
def set(self, setting: IntGroupChatSettings, value: int) -> None: ...
def set(self, setting: Any, value: Any) -> None:
app.settings.set_group_chat_setting(
self._account, str(self._jid), setting, value)
self._account, self._jid, setting, value)
class Contacts(BaseModule):
......@@ -228,7 +228,7 @@ class BareContact(CommonContact):
def __init__(self, logger: logging.Logger, jid: JID, account: str) -> None:
CommonContact.__init__(self, logger, jid, account)
self.settings = ContactSettings(account, str(jid))
self.settings = ContactSettings(account, jid)
self._avatar_sha = app.storage.cache.get_contact(jid, 'avatar')
......@@ -474,7 +474,7 @@ class GroupchatContact(CommonContact):
def __init__(self, logger: logging.Logger, jid: JID, account: str) -> None:
CommonContact.__init__(self, logger, jid, account)
self.settings = GroupChatSettings(account, str(jid))
self.settings = GroupChatSettings(account, jid)
@property
def is_groupchat(self) -> bool:
......
......@@ -705,27 +705,27 @@ def set_account_setting(self,
@overload
def get_group_chat_setting(self,
account: str,
jid: Union[str, JID],
jid: JID,
setting: IntGroupChatSettings
) -> int: ...
@overload
def get_group_chat_setting(self,
account: str,
jid: Union[str, JID],
jid: JID,
setting: BoolGroupChatSettings
) -> bool: ...
@overload
def get_group_chat_setting(self,
account: str,
jid: Union[str, JID],
jid: JID,
setting: StringGroupChatSettings
) -> str: ...
def get_group_chat_setting(self,
account: str,
jid: Union[str, JID],
jid: JID,
setting: AllGroupChatSettings
) -> AllGroupChatSettingsT:
......@@ -766,27 +766,27 @@ def get_group_chat_setting(self,
@overload
def set_group_chat_setting(self,
account: str,
jid: str,
jid: JID,
setting: StringGroupChatSettings,
value: str) -> None: ...
@overload
def set_group_chat_setting(self,
account: str,
jid: str,
jid: JID,
setting: IntGroupChatSettings,
value: int) -> None: ...
@overload
def set_group_chat_setting(self,
account: str,
jid: str,
jid: JID,
setting: BoolGroupChatSettings,
value: bool) -> None: ...
def set_group_chat_setting(self,
account: str,
jid: str,
jid: JID,
setting: AllGroupChatSettings,
value: AllGroupChatSettingsT) -> None:
......@@ -851,7 +851,7 @@ def set_group_chat_settings(self,
def get_contact_setting(self,
account: str,
jid: str,
jid: JID,
setting: str) -> SETTING_TYPE:
if account not in self._account_settings:
......@@ -874,7 +874,7 @@ def get_contact_setting(self,
def set_contact_setting(self,
account: str,
jid: str,
jid: JID,
setting: str,
value: SETTING_TYPE) -> None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment