comparison sat/memory/sqla.py @ 3797:cc653b2685f0

core (memory/sqla), plugin XEP-0359: always add `origin-id`, and store: `origin-id` is now always added to messages, and it is stored to database in the new column instead of `extra` when present.
author Goffi <goffi@goffi.org>
date Fri, 17 Jun 2022 14:15:23 +0200
parents af485e8afe03
children b5013bada4b6
comparison
equal deleted inserted replaced
3796:24c1c06c865b 3797:cc653b2685f0
562 # while we were offline, using MAM (XEP-0313). 562 # while we were offline, using MAM (XEP-0313).
563 if (filters['last_stanza_id'] is not True 563 if (filters['last_stanza_id'] is not True
564 or limit != 1): 564 or limit != 1):
565 raise ValueError("Unexpected values for last_stanza_id filter") 565 raise ValueError("Unexpected values for last_stanza_id filter")
566 stmt = stmt.where(History.stanza_id.is_not(None)) 566 stmt = stmt.where(History.stanza_id.is_not(None))
567 if 'origin_id' in filters:
568 stmt = stmt.where(History.origin_id == filters["origin_id"])
567 569
568 if limit is not None: 570 if limit is not None:
569 stmt = stmt.limit(limit) 571 stmt = stmt.limit(limit)
570 572
571 async with self.session() as session: 573 async with self.session() as session:
594 try: 596 try:
595 async with self.session() as session: 597 async with self.session() as session:
596 async with session.begin(): 598 async with session.begin():
597 session.add(History( 599 session.add(History(
598 uid=data["uid"], 600 uid=data["uid"],
601 origin_id=data["extra"].get("origin_id"),
599 stanza_id=data["extra"].get("stanza_id"), 602 stanza_id=data["extra"].get("stanza_id"),
600 update_uid=data["extra"].get("update_uid"), 603 update_uid=data["extra"].get("update_uid"),
601 profile_id=self.profiles[profile], 604 profile_id=self.profiles[profile],
602 source_jid=data["from"], 605 source_jid=data["from"],
603 dest_jid=data["to"], 606 dest_jid=data["to"],