slidge.space¶
Managing Spaces XEP-0503
Spaces are a collection of rooms.
Package Contents¶
- class slidge.space.LegacySpaceNodes[SpaceT: slidge.space.space.LegacySpace](session: slidge.util.types.AnySession)¶
A class to manage XEP-0503 spaces.
It is accessible through the
.spacesattribute of theslidge.BaseSessionof a given user.- async create(legacy_id: str) ChildT¶
Create a new Contact, Space or Space.
This must raise if legacy id does not map to something existing.
A typical pattern is to have a method constructing a
Contactor aRoomfrom a “metadata struct” provided by the legacy network, in the spirit of:class LegacyRoster[Contact]: def create(self, legacy_id: str) -> Contact: meta = self._session.legacy_client.fetch_contact(legacy_id) if meta is None: raise XMPPError("item-not-found", f"No contact {legacy_id!r}") return await self.get_or_create_by_meta(meta) def get_or_create_by_meta(self, meta: legacy_lib.ContactMetadata) -> Contact: contact = self.get(meta.id) or self._create(legacy_id) contact.set_meta(meta) return contact
- async get_or_create(legacy_id: str, *args: object) ChildT¶
Get an existing Recipient or Space or
create()it if does not exist.
- async fill() collections.abc.AsyncIterator[ChildT]¶
This is called once on startup, and should yield recipients with updated metadata.