M matteridge/__main__.py => matteridge/__main__.py +2 -5
@@ 1,11 1,8 @@
-import sys
-
-from slidge.__main__ import main as slidge_main
+from slidge import entrypoint
def main() -> None:
- sys.argv.extend(["--legacy", "matteridge"])
- slidge_main()
+ entrypoint("matteridge")
if __name__ == "__main__":
M matteridge/contact.py => matteridge/contact.py +1 -1
@@ 278,7 278,7 @@ class Roster(LegacyRoster[str, Contact]):
for username, user in users.items():
contact = await self.by_legacy_id(username, user)
contact.is_friend = True
- await contact.add_to_roster()
+ yield contact
async def known_user_ids(self, only_friends=False, including_me=True):
me = await self.mm.mm_id
M matteridge/group.py => matteridge/group.py +11 -4
@@ 3,6 3,7 @@ from typing import TYPE_CHECKING, Optional
from mattermost_api_reference_client.models import Channel, ChannelMember, Team
from slidge import LegacyBookmarks, LegacyMUC, LegacyParticipant, MucType, global_config
+from slidge.util.types import HoleBound
from slixmpp.exceptions import XMPPError
from . import config
@@ 112,20 113,26 @@ class MUC(LegacyMUC[str, str, Participant, str]):
contact = await self.session.contacts.by_mm_user_id(
user_id, users.get(user_id)
)
- await self.get_participant_by_contact(contact)
+ yield await self.get_participant_by_contact(contact)
async def backfill(
self,
- oldest_message_id: Optional[str] = None,
- oldest_message_date: Optional[datetime] = None,
+ after: Optional[HoleBound] = None,
+ before: Optional[HoleBound] = None,
):
if not config.BACKFILL_POSTS:
return
now = datetime.now()
i = 0
+ self.log.info("Backfill request between %s and %s", before, after)
+ before_id = None if before is None else before.id
+ after_id = None if after is None else after.id
async for post in self.session.mm_client.get_posts_for_channel(
- self.legacy_id, before=oldest_message_id
+ self.legacy_id, before=before_id
):
+ if post.id == after_id:
+ break
+
if i == 0 and not self.xmpp.cache.msg_id_get(
await self.session.mm_client.mm_id, self.legacy_id
):
M matteridge/session.py => matteridge/session.py +3 -4
@@ 78,7 78,7 @@ class Session(BaseSession[str, Recipient]):
self._update_status_task: Optional[asyncio.Task] = None
def __init_ws(self):
- f = self.user.registration_form
+ f = self.user.legacy_module_data
self.ws = Websocket(
re.sub("^http", "ws", f["url"].rstrip("/") or "") # type:ignore
+ (f["basepath"] or "")
@@ 122,10 122,9 @@ class Session(BaseSession[str, Recipient]):
return True
def update_token(self, token: str):
- self.user.registration_form["token"] = token
- self.user.commit()
+ self.legacy_module_data_update({"token": token})
self.mm_client = get_client_from_registration_form(
- self.user.registration_form, self.xmpp.cache
+ self.user.legacy_module_data, self.xmpp.cache # type:ignore
)
async def login(self):
M pyproject.toml => pyproject.toml +2 -2
@@ 6,11 6,11 @@ authors = ["nicoco <nicoco@nicoco.fr>"]
readme = "README.md"
[tool.poetry.dependencies]
-python = "^3.9"
+python = "^3.11"
mattermost-api-reference-client = "^4.0.0.post3"
emoji = "^2.2.0"
async-lru = "^2.0.4"
-slidge = "~0.1"
+slidge = "0.2.0a3"
[tool.poetry.group.dev.dependencies]
pytest-asyncio = "^0.21.0"