comparison libervia/backend/plugins/plugin_xep_0308.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents b1207332cea2
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
33 from libervia.backend.core.log import getLogger 33 from libervia.backend.core.log import getLogger
34 from libervia.backend.memory.sqla import History, Message, Subject, joinedload, select 34 from libervia.backend.memory.sqla import History, Message, Subject, joinedload, select
35 from libervia.backend.models.core import MessageData, MessageEdition 35 from libervia.backend.models.core import MessageData, MessageEdition
36 from libervia.backend.tools.common import data_format 36 from libervia.backend.tools.common import data_format
37 from libervia.backend.tools.utils import aio 37 from libervia.backend.tools.utils import aio
38
38 log = getLogger(__name__) 39 log = getLogger(__name__)
39 40
40 41
41 PLUGIN_INFO = { 42 PLUGIN_INFO = {
42 C.PI_NAME: "Last Message Correction", 43 C.PI_NAME: "Last Message Correction",
137 # extra may be important for rich content 138 # extra may be important for rich content
138 previous_version["extra"] = previous_extra 139 previous_version["extra"] = previous_extra
139 140
140 if store: 141 if store:
141 flag_modified(edited_history, "extra") 142 flag_modified(edited_history, "extra")
142 edited_history.extra.setdefault(C.MESS_EXTRA_EDITIONS, []).append(previous_version) 143 edited_history.extra.setdefault(C.MESS_EXTRA_EDITIONS, []).append(
144 previous_version
145 )
143 await self.host.memory.storage.add(edited_history) 146 await self.host.memory.storage.add(edited_history)
144 147
145 edit_data = MessageData(edited_history.serialise()) 148 edit_data = MessageData(edited_history.serialise())
146 self.host.bridge.message_update( 149 self.host.bridge.message_update(
147 edited_history.uid, 150 edited_history.uid,
269 edit_data.extra, 272 edit_data.extra,
270 last_mess[4], 273 last_mess[4],
271 last_mess[5], 274 last_mess[5],
272 last_mess[-1], 275 last_mess[-1],
273 # message will be updated and signal sent on reception in group chat 276 # message will be updated and signal sent on reception in group chat
274 store = not is_group_chat 277 store=not is_group_chat,
275 ) 278 )
276 279
277 serialised = edited_history.serialise() 280 serialised = edited_history.serialise()
278 serialised["uid"] = str(uuid.uuid4()) 281 serialised["uid"] = str(uuid.uuid4())
279 serialised["from"] = client.jid 282 serialised["from"] = client.jid