Mercurial > libervia-backend
annotate libervia/backend/core/core_types.py @ 4304:92a886f31581 default tip @
doc (components): new Email gateway documentation:
fix 449
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Sep 2024 18:07:44 +0200 |
parents | 96fdf4891747 |
children |
rev | line source |
---|---|
3537
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 # Libervia types |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
19 from collections import namedtuple |
4033
5a42c7842556
core (plugins): implementation of XEP-0215 "External Service Discovery":
Goffi <goffi@goffi.org>
parents:
3911
diff
changeset
|
20 from typing import Dict, Callable, Optional |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
21 from typing_extensions import TypedDict |
4033
5a42c7842556
core (plugins): implementation of XEP-0215 "External Service Discovery":
Goffi <goffi@goffi.org>
parents:
3911
diff
changeset
|
22 |
3679
b02fb5fcaa30
core (core_types): add `jid` to `SatXMPPEntity`
Goffi <goffi@goffi.org>
parents:
3537
diff
changeset
|
23 from twisted.words.protocols.jabber import jid as t_jid |
4033
5a42c7842556
core (plugins): implementation of XEP-0215 "External Service Discovery":
Goffi <goffi@goffi.org>
parents:
3911
diff
changeset
|
24 from twisted.words.protocols.jabber import xmlstream |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
25 from twisted.words.xish import domish |
4286
96fdf4891747
component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
26 from wokkel import disco |
3679
b02fb5fcaa30
core (core_types): add `jid` to `SatXMPPEntity`
Goffi <goffi@goffi.org>
parents:
3537
diff
changeset
|
27 |
3537
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
f9a5b810f14d
core (memory/storage): backend storage is now based on SQLAlchemy
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 class SatXMPPEntity: |
3679
b02fb5fcaa30
core (core_types): add `jid` to `SatXMPPEntity`
Goffi <goffi@goffi.org>
parents:
3537
diff
changeset
|
30 |
4044
3900626bc100
plugin XEP-0166: refactoring, and various improvments:
Goffi <goffi@goffi.org>
parents:
4033
diff
changeset
|
31 profile: str |
3679
b02fb5fcaa30
core (core_types): add `jid` to `SatXMPPEntity`
Goffi <goffi@goffi.org>
parents:
3537
diff
changeset
|
32 jid: t_jid.JID |
4131
c38c33a44171
core (types): add `is_admin` to `SatXMPPEntity`
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
33 is_admin: bool |
3812
722a38e78fd1
core (types): add `is_component` to `SatXMPPEntity`
Goffi <goffi@goffi.org>
parents:
3679
diff
changeset
|
34 is_component: bool |
4033
5a42c7842556
core (plugins): implementation of XEP-0215 "External Service Discovery":
Goffi <goffi@goffi.org>
parents:
3911
diff
changeset
|
35 server_jid: t_jid.JID |
5a42c7842556
core (plugins): implementation of XEP-0215 "External Service Discovery":
Goffi <goffi@goffi.org>
parents:
3911
diff
changeset
|
36 IQ: Callable[[Optional[str], Optional[int]], xmlstream.IQ] |
4286
96fdf4891747
component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
37 identities: list[disco.DiscoIdentity] |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
38 |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
39 |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
40 EncryptionPlugin = namedtuple( |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
41 "EncryptionPlugin", ("instance", "name", "namespace", "priority", "directed") |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
42 ) |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
43 |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
44 |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
45 class EncryptionSession(TypedDict): |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
46 plugin: EncryptionPlugin |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
47 |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
48 |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
49 # Incomplete types built through observation rather than code inspection. |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
50 MessageDataExtra = TypedDict( |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
51 "MessageDataExtra", {"encrypted": bool, "origin_id": str}, total=False |
3911
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
52 ) |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
53 |
8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
Syndace <me@syndace.dev>
parents:
3812
diff
changeset
|
54 |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
55 MessageData = TypedDict( |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
56 "MessageData", |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
57 { |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
58 "from": t_jid.JID, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
59 "to": t_jid.JID, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
60 "uid": str, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
61 "message": Dict[str, str], |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
62 "subject": Dict[str, str], |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
63 "type": str, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
64 "timestamp": float, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
65 "extra": MessageDataExtra, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
66 "ENCRYPTION": EncryptionSession, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
67 "xml": domish.Element, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
68 }, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
69 total=False, |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4131
diff
changeset
|
70 ) |