summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Buquet <pep@bouah.net>2020-05-25 18:49:32 +0200
committerMaxime Buquet <pep@bouah.net>2020-05-25 18:49:32 +0200
commit5b8e46c9a79f4086ce0a5e6d4d34e21594cd1e4f (patch)
tree1d60efba78f49ec485780d4bff6ee2bed921e187
parent50d97b4c3ceefd79102c5d22531d79d56dc4971e (diff)
parent6896efb7e6c3f92ac44b7d2950ded5cf8d95ac06 (diff)
downloadpoezio-5b8e46c9a79f4086ce0a5e6d4d34e21594cd1e4f.tar.gz
poezio-5b8e46c9a79f4086ce0a5e6d4d34e21594cd1e4f.tar.bz2
poezio-5b8e46c9a79f4086ce0a5e6d4d34e21594cd1e4f.tar.xz
poezio-5b8e46c9a79f4086ce0a5e6d4d34e21594cd1e4f.zip
Merge branch 'mam-onetoone-nick-fix' into 'master'
Fix mam own nick in one to one tabs See merge request poezio/poezio!122
-rw-r--r--poezio/mam.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/poezio/mam.py b/poezio/mam.py
index 371b34dd..31ca2f0c 100644
--- a/poezio/mam.py
+++ b/poezio/mam.py
@@ -46,8 +46,9 @@ def make_line(
tab: tabs.ChatTab,
text: str,
time: datetime,
- nick: str,
+ jid: JID,
identifier: str = '',
+ deterministic: bool = True,
) -> Message:
"""Adds a textual entry in the TextBuffer"""
@@ -55,9 +56,8 @@ def make_line(
time = time.replace(tzinfo=timezone.utc).astimezone(tz=None)
time = time.replace(tzinfo=None)
- deterministic = config.get_by_tabname('deterministic_nick_colors', tab.jid.bare)
if isinstance(tab, tabs.MucTab):
- nick = nick.split('/')[1]
+ nick = jid.resource
user = tab.get_user_by_name(nick)
if deterministic:
if user:
@@ -76,11 +76,12 @@ def make_line(
color = xhtml.colors.get(color)
color = (color, -1)
else:
- if nick.split('/')[0] == tab.core.xmpp.boundjid.bare:
+ if jid.bare == tab.core.xmpp.boundjid.bare:
+ nick = tab.core.own_nick
color = get_theme().COLOR_OWN_NICK
else:
color = get_theme().COLOR_REMOTE_USER
- nick = tab.get_nick()
+ nick = tab.get_nick()
return Message(
txt=text,
identifier=identifier,
@@ -133,7 +134,7 @@ def _parse_message(msg: SMessage) -> Dict:
message = forwarded['stanza']
return {
'time': forwarded['delay']['stamp'],
- 'nick': str(message['from']),
+ 'jid': message['from'],
'text': message['body'],
'identifier': message['origin-id']
}
@@ -147,13 +148,17 @@ async def retrieve_messages(tab: tabs.ChatTab,
msg_count = 0
msgs = []
to_add = []
+ deterministic = config.get_by_tabname(
+ 'deterministic_nick_colors',
+ tab.jid.bare
+ )
try:
async for rsm in results:
for msg in rsm['mam']['results']:
if msg['mam_result']['forwarded']['stanza'] \
.xml.find('{%s}%s' % ('jabber:client', 'body')) is not None:
args = _parse_message(msg)
- msgs.append(make_line(tab, **args))
+ msgs.append(make_line(tab, deterministic=deterministic, **args))
for msg in reversed(msgs):
to_add.append(msg)
msg_count += 1