1
0
Fork 0

fix: do not set subject in rooms without description

Setting the subject in rooms that don't have one
resulted in an empty subject with a timestamp of
'0001-01-01T00:00:00Z', which in turned raise warnings
in gajim's logs.

This commit changes the behaviour setting a subject
and a subject date only if they are given by WA's
servers.
This commit is contained in:
nicoco 2024-02-29 21:39:38 +01:00
parent d32f1f0a9e
commit c4af612543
1 changed files with 10 additions and 8 deletions

View File

@ -100,15 +100,17 @@ class MUC(LegacyMUC[str, str, Participant, str]):
self.user_nick = info.Nickname
if info.Name:
self.name = info.Name
if info.Subject.Subject or info.Subject.SetAt:
if info.Subject.Subject:
self.subject = info.Subject.Subject
if info.Subject.SetAt:
set_at = datetime.fromtimestamp(info.Subject.SetAt, tz=timezone.utc)
self.subject_date = set_at
if info.Subject.SetByJID:
participant = await self.get_participant_by_legacy_id(info.Subject.SetByJID)
if name := participant.nickname:
self.subject_setter = name
if info.Subject.SetAt:
set_at = datetime.fromtimestamp(info.Subject.SetAt, tz=timezone.utc)
self.subject_date = set_at
if info.Subject.SetByJID:
participant = await self.get_participant_by_legacy_id(
info.Subject.SetByJID
)
if name := participant.nickname:
self.subject_setter = name
for data in info.Participants:
participant = await self.get_participant_by_legacy_id(data.JID)
if data.Action == whatsapp.GroupParticipantActionRemove: