dimples 1.4.2__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dimples-1.4.2 → dimples-1.5.0}/PKG-INFO +6 -6
- {dimples-1.4.2 → dimples-1.5.0}/README.md +5 -5
- {dimples-1.4.2 → dimples-1.5.0}/dimples/__init__.py +11 -3
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/checker.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/creator.py +8 -6
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_invite.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_reset.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/facebook.py +6 -26
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/packer.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/__init__.py +5 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/ans.py +58 -1
- dimples-1.5.0/dimples/common/archivist.py +106 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/compat/__init__.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/compat/address.py +2 -1
- dimples-1.5.0/dimples/common/compat/compatible.py +379 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/compat/entity.py +2 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/compat/loader.py +51 -5
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/compat/meta.py +1 -21
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/facebook.py +71 -16
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/messenger.py +21 -13
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/__init__.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/block.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/customized.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/group.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/mute.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/password.py +3 -2
- dimples-1.5.0/dimples/common/protocol/roles.py +105 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/version.py +8 -8
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/register.py +8 -6
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/document.py +2 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/group.py +3 -3
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/user.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/document.py +4 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/group.py +3 -3
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/user.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_cipherkey.py +2 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_document.py +5 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/edge/messenger.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/edge/octopus.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/edge/shared.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/emitter.py +9 -7
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/admin.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/builder.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/delegate.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/emitter.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/manager.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/register/base.py +16 -11
- {dimples-1.4.2 → dimples-1.5.0}/dimples/register/ext.py +11 -9
- {dimples-1.4.2 → dimples-1.5.0}/dimples/register/shared.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/checker.py +2 -2
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/creator.py +4 -4
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/document.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/dispatcher.py +4 -4
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/facebook.py +1 -23
- {dimples-1.4.2 → dimples-1.5.0}/dimples/station/shared.py +1 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples/utils/__init__.py +2 -0
- dimples-1.5.0/dimples/utils/thanos.py +83 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples.egg-info/PKG-INFO +6 -6
- {dimples-1.4.2 → dimples-1.5.0}/dimples.egg-info/SOURCES.txt +3 -1
- {dimples-1.4.2 → dimples-1.5.0}/dimples.egg-info/requires.txt +3 -2
- {dimples-1.4.2 → dimples-1.5.0}/setup.py +6 -6
- dimples-1.4.2/dimples/common/archivist.py +0 -141
- dimples-1.4.2/dimples/common/compat/compatible.py +0 -234
- {dimples-1.4.2 → dimples-1.5.0}/LICENSE +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/checkpoint.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/commands.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/customized.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/group.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_expel.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_join.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_query.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_quit.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/grp_resign.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/cpu/handshake.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/messenger.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/network/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/network/session.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/network/state.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/network/transition.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/processor.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/client/terminal.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/anonymous.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/checker.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/compat/network.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/dbi/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/dbi/account.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/dbi/message.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/dbi/session.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/packer.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/processer.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/ans.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/handshake.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/login.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/report.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/protocol/utils.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/queue.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/common/session.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/flexible.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/gate.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/gatekeeper.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/mars.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/mtp.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/protocol/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/protocol/mars.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/protocol/ws.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/queue.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/seeker.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/session.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/conn/ws.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/account.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/base.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/group_history.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/group_keys.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/login.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/meta.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/private.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/dos/station.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/message.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/base.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/grp_history.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/grp_keys.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/login.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/message.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/meta.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/redis/station.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/session.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_base.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_group.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_group_history.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_group_keys.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_login.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_message.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_meta.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_private.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_station.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/database/t_user.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/edge/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/edge/start.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/helper.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/packer.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/group/shared.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/register/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/register/run.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/ans.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/handshake.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/login.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/cpu/report.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/deliver.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/dis_roamer.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/messenger.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/packer.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/processor.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/push.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/session.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/session_center.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/server/trace.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/station/__init__.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/station/handler.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/station/start.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/utils/cache.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/utils/checker.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/utils/config.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/utils/http.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples/utils/log.py +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples.egg-info/dependency_links.txt +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples.egg-info/entry_points.txt +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/dimples.egg-info/top_level.txt +0 -0
- {dimples-1.4.2 → dimples-1.5.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dimples
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: DIMP Library for Edges and Stations
|
|
5
5
|
Home-page: https://github.com/dimchat/demo-py
|
|
6
6
|
Author: Albert Moky
|
|
@@ -36,12 +36,12 @@ License-File: LICENSE
|
|
|
36
36
|
# 'pycryptodome', # 3.14.1
|
|
37
37
|
# 'base58', # 1.0.3
|
|
38
38
|
# 'ecdsa', # 0.16.1
|
|
39
|
-
'dimplugins>=2.
|
|
39
|
+
'dimplugins>=2.3.0',
|
|
40
40
|
|
|
41
|
-
'dimsdk>=2.
|
|
42
|
-
# 'dimp>=2.
|
|
43
|
-
# 'dkd>=2.
|
|
44
|
-
# 'mkm>=2.
|
|
41
|
+
'dimsdk>=2.3.0',
|
|
42
|
+
# 'dimp>=2.3.0',
|
|
43
|
+
# 'dkd>=2.3.0',
|
|
44
|
+
# 'mkm>=2.3.0',
|
|
45
45
|
|
|
46
46
|
'startrek>=2.2.2',
|
|
47
47
|
'tcp>=2.2.2',
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
# 'pycryptodome', # 3.14.1
|
|
23
23
|
# 'base58', # 1.0.3
|
|
24
24
|
# 'ecdsa', # 0.16.1
|
|
25
|
-
'dimplugins>=2.
|
|
25
|
+
'dimplugins>=2.3.0',
|
|
26
26
|
|
|
27
|
-
'dimsdk>=2.
|
|
28
|
-
# 'dimp>=2.
|
|
29
|
-
# 'dkd>=2.
|
|
30
|
-
# 'mkm>=2.
|
|
27
|
+
'dimsdk>=2.3.0',
|
|
28
|
+
# 'dimp>=2.3.0',
|
|
29
|
+
# 'dkd>=2.3.0',
|
|
30
|
+
# 'mkm>=2.3.0',
|
|
31
31
|
|
|
32
32
|
'startrek>=2.2.2',
|
|
33
33
|
'tcp>=2.2.2',
|
|
@@ -108,6 +108,12 @@ __all__ = [
|
|
|
108
108
|
'BaseDataWrapper',
|
|
109
109
|
'BaseFileWrapper',
|
|
110
110
|
|
|
111
|
+
#
|
|
112
|
+
# Algorithm
|
|
113
|
+
#
|
|
114
|
+
'AsymmetricAlgorithms', 'SymmetricAlgorithms',
|
|
115
|
+
'EncodeAlgorithms',
|
|
116
|
+
|
|
111
117
|
#
|
|
112
118
|
# MingKeMing
|
|
113
119
|
#
|
|
@@ -118,6 +124,8 @@ __all__ = [
|
|
|
118
124
|
'Meta',
|
|
119
125
|
'Document', 'Visa', 'Bulletin',
|
|
120
126
|
|
|
127
|
+
'MetaType', 'DocumentType',
|
|
128
|
+
|
|
121
129
|
'AddressFactory',
|
|
122
130
|
'IDFactory',
|
|
123
131
|
'MetaFactory',
|
|
@@ -211,7 +219,7 @@ __all__ = [
|
|
|
211
219
|
|
|
212
220
|
'ServiceProvider', 'Station', 'Bot',
|
|
213
221
|
|
|
214
|
-
'MemberType',
|
|
222
|
+
# 'MemberType',
|
|
215
223
|
|
|
216
224
|
'MetaUtils', 'DocumentUtils',
|
|
217
225
|
|
|
@@ -238,7 +246,7 @@ __all__ = [
|
|
|
238
246
|
'TwinsHelper',
|
|
239
247
|
|
|
240
248
|
'AddressNameService',
|
|
241
|
-
'Archivist',
|
|
249
|
+
# 'Archivist',
|
|
242
250
|
'Facebook', 'Messenger',
|
|
243
251
|
'MessageProcessor', 'MessagePacker',
|
|
244
252
|
|
|
@@ -322,7 +330,7 @@ __all__ = [
|
|
|
322
330
|
#
|
|
323
331
|
####################################
|
|
324
332
|
|
|
325
|
-
'
|
|
333
|
+
'MetaVersion',
|
|
326
334
|
'Password',
|
|
327
335
|
'BroadcastUtils',
|
|
328
336
|
|
|
@@ -246,6 +246,6 @@ class ClientChecker(EntityChecker, Logging):
|
|
|
246
246
|
self.debug(msg='visa response not expired yet: %s' % receiver)
|
|
247
247
|
return False
|
|
248
248
|
self.info(msg='push visa document: %s => %s' % (me, receiver))
|
|
249
|
-
content = DocumentCommand.response(
|
|
249
|
+
content = DocumentCommand.response(identifier=me, meta=None, documents=[visa])
|
|
250
250
|
_, r_msg = await messenger.send_content(content=content, sender=me, receiver=receiver, priority=1)
|
|
251
251
|
return r_msg is not None
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
|
-
from typing import Optional
|
|
31
|
+
from typing import Optional
|
|
32
32
|
|
|
33
33
|
from dimsdk import ContentType
|
|
34
34
|
from dimsdk import Command, GroupCommand
|
|
@@ -55,18 +55,20 @@ from .customized import CustomizedContentProcessor
|
|
|
55
55
|
class ClientContentProcessorCreator(BaseContentProcessorCreator):
|
|
56
56
|
|
|
57
57
|
# Override
|
|
58
|
-
def create_content_processor(self, msg_type:
|
|
58
|
+
def create_content_processor(self, msg_type: str) -> Optional[ContentProcessor]:
|
|
59
59
|
# application customized
|
|
60
|
-
if msg_type == ContentType.APPLICATION
|
|
60
|
+
if msg_type == ContentType.APPLICATION or msg_type == 'application':
|
|
61
61
|
return CustomizedContentProcessor(facebook=self.facebook, messenger=self.messenger)
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if msg_type == ContentType.CUSTOMIZED or msg_type == 'customized':
|
|
63
|
+
return CustomizedContentProcessor(facebook=self.facebook, messenger=self.messenger)
|
|
64
|
+
# history command
|
|
65
|
+
if msg_type == ContentType.HISTORY or msg_type == 'history':
|
|
64
66
|
return HistoryCommandProcessor(facebook=self.facebook, messenger=self.messenger)
|
|
65
67
|
# others
|
|
66
68
|
return super().create_content_processor(msg_type=msg_type)
|
|
67
69
|
|
|
68
70
|
# Override
|
|
69
|
-
def create_command_processor(self, msg_type:
|
|
71
|
+
def create_command_processor(self, msg_type: str, cmd: str) -> Optional[ContentProcessor]:
|
|
70
72
|
# receipt
|
|
71
73
|
if cmd == Command.RECEIPT:
|
|
72
74
|
return ReceiptCommandProcessor(facebook=self.facebook, messenger=self.messenger)
|
|
@@ -117,7 +117,7 @@ class InviteCommandProcessor(GroupCommandProcessor):
|
|
|
117
117
|
# if we received the 'invite' command here, maybe it was confused,
|
|
118
118
|
# anyway, we just append the new members directly.
|
|
119
119
|
self.warning(msg='invited by administrator: %s, group: %s' % (sender, group))
|
|
120
|
-
content['added'] = ID.revert(added_list)
|
|
120
|
+
content['added'] = ID.revert(identifiers=added_list)
|
|
121
121
|
else:
|
|
122
122
|
# DB error?
|
|
123
123
|
assert False, 'failed to save members for group: %s' % group
|
|
@@ -118,9 +118,9 @@ class ResetCommandProcessor(GroupCommandProcessor):
|
|
|
118
118
|
elif await self._save_members(members=new_members, group=group):
|
|
119
119
|
self.info(msg='new members saved in group: %s' % group)
|
|
120
120
|
if len(add_list) > 0:
|
|
121
|
-
content['added'] = ID.revert(add_list)
|
|
121
|
+
content['added'] = ID.revert(identifiers=add_list)
|
|
122
122
|
if len(remove_list) > 0:
|
|
123
|
-
content['removed'] = ID.revert(remove_list)
|
|
123
|
+
content['removed'] = ID.revert(identifiers=remove_list)
|
|
124
124
|
else:
|
|
125
125
|
# DB error?
|
|
126
126
|
assert False, 'failed to save members for group: %s' % group
|
|
@@ -34,7 +34,7 @@ from typing import Optional, List
|
|
|
34
34
|
|
|
35
35
|
from dimsdk import EntityType
|
|
36
36
|
from dimsdk import ID, Document, Bulletin
|
|
37
|
-
from dimsdk import
|
|
37
|
+
from dimsdk import Group
|
|
38
38
|
|
|
39
39
|
from ..utils import Runner
|
|
40
40
|
from ..common import BroadcastUtils
|
|
@@ -45,31 +45,11 @@ from ..group import SharedGroupManager
|
|
|
45
45
|
class ClientFacebook(CommonFacebook):
|
|
46
46
|
|
|
47
47
|
# Override
|
|
48
|
-
def
|
|
49
|
-
group
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async def select_user(self, receiver: ID) -> Optional[User]:
|
|
54
|
-
if receiver.is_user:
|
|
55
|
-
return await super().select_user(receiver=receiver)
|
|
56
|
-
# group message(recipient not designated)
|
|
57
|
-
assert receiver.is_group, 'receiver error: %s' % receiver
|
|
58
|
-
# the messenger will check group info before decrypting message,
|
|
59
|
-
# so we can trust that the group's meta & members MUST exist here.
|
|
60
|
-
users = await self.archivist.local_users
|
|
61
|
-
if users is None or len(users) == 0:
|
|
62
|
-
self.error(msg='local users should not be empty')
|
|
63
|
-
return None
|
|
64
|
-
elif receiver.is_broadcast:
|
|
65
|
-
# broadcast message can decrypt by anyone, so just return current user
|
|
66
|
-
return users[0]
|
|
67
|
-
members = await self.get_members(identifier=receiver)
|
|
68
|
-
# assert len(members) > 0, 'members not found: %s' % receiver
|
|
69
|
-
for item in users:
|
|
70
|
-
if item.identifier in members:
|
|
71
|
-
# DISCUSS: set this item to be current user?
|
|
72
|
-
return item
|
|
48
|
+
async def get_group(self, identifier: ID) -> Optional[Group]:
|
|
49
|
+
group = await super().get_group(identifier=identifier)
|
|
50
|
+
if group is not None:
|
|
51
|
+
group.data_source = SharedGroupManager()
|
|
52
|
+
return group
|
|
73
53
|
|
|
74
54
|
# Override
|
|
75
55
|
async def save_document(self, document: Document) -> bool:
|
|
@@ -90,7 +90,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
90
90
|
error = {
|
|
91
91
|
'message': 'encrypt keys not found',
|
|
92
92
|
'group': str(receiver),
|
|
93
|
-
'members': ID.revert(
|
|
93
|
+
'members': ID.revert(identifiers=waiting),
|
|
94
94
|
}
|
|
95
95
|
self.messenger.suspend_instant_message(msg=msg, error=error)
|
|
96
96
|
# perhaps some members have already disappeared,
|
|
@@ -34,6 +34,7 @@ from .dbi import *
|
|
|
34
34
|
|
|
35
35
|
from .anonymous import Anonymous
|
|
36
36
|
from .register import Register
|
|
37
|
+
from .ans import AddressNameService
|
|
37
38
|
from .ans import AddressNameServer, ANSFactory
|
|
38
39
|
|
|
39
40
|
from .checker import EntityChecker
|
|
@@ -48,7 +49,7 @@ from .session import Transmitter, Session
|
|
|
48
49
|
|
|
49
50
|
__all__ = [
|
|
50
51
|
|
|
51
|
-
'
|
|
52
|
+
'MetaVersion',
|
|
52
53
|
'Password',
|
|
53
54
|
'BroadcastUtils',
|
|
54
55
|
|
|
@@ -91,7 +92,9 @@ __all__ = [
|
|
|
91
92
|
#
|
|
92
93
|
|
|
93
94
|
'Anonymous',
|
|
94
|
-
'
|
|
95
|
+
'AddressNameService',
|
|
96
|
+
'AddressNameServer',
|
|
97
|
+
'ANSFactory',
|
|
95
98
|
|
|
96
99
|
'EntityChecker',
|
|
97
100
|
'CommonArchivist',
|
|
@@ -30,11 +30,68 @@
|
|
|
30
30
|
A map for short name to ID, just like DNS
|
|
31
31
|
"""
|
|
32
32
|
|
|
33
|
+
from abc import ABC, abstractmethod
|
|
33
34
|
from typing import Optional, List, Dict
|
|
34
35
|
|
|
35
36
|
from dimsdk import Address, ID, IDFactory
|
|
36
37
|
from dimsdk import ANYONE, EVERYONE, FOUNDER
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class AddressNameService(ABC):
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# Reserved names
|
|
44
|
+
#
|
|
45
|
+
KEYWORDS = [
|
|
46
|
+
"all", "everyone", "anyone", "owner", "founder",
|
|
47
|
+
# --------------------------------
|
|
48
|
+
"dkd", "mkm", "dimp", "dim", "dimt",
|
|
49
|
+
"rsa", "ecc", "aes", "des", "btc", "eth",
|
|
50
|
+
# --------------------------------
|
|
51
|
+
"crypto", "key", "symmetric", "asymmetric",
|
|
52
|
+
"public", "private", "secret", "password",
|
|
53
|
+
"id", "address", "meta",
|
|
54
|
+
"tai", "document", "profile", "visa", "bulletin",
|
|
55
|
+
"entity", "user", "group", "contact",
|
|
56
|
+
# --------------------------------
|
|
57
|
+
"member", "admin", "administrator", "assistant",
|
|
58
|
+
"main", "polylogue", "chatroom",
|
|
59
|
+
"social", "organization",
|
|
60
|
+
"company", "school", "government", "department",
|
|
61
|
+
"provider", "station", "thing", "bot", "robot",
|
|
62
|
+
# --------------------------------
|
|
63
|
+
"message", "instant", "secure", "reliable",
|
|
64
|
+
"envelope", "sender", "receiver", "time",
|
|
65
|
+
"content", "forward", "command", "history",
|
|
66
|
+
"keys", "data", "signature",
|
|
67
|
+
# --------------------------------
|
|
68
|
+
"type", "serial", "sn",
|
|
69
|
+
"text", "file", "image", "audio", "video", "page",
|
|
70
|
+
"handshake", "receipt", "block", "mute",
|
|
71
|
+
"register", "suicide", "found", "abdicate",
|
|
72
|
+
"invite", "expel", "join", "quit", "reset", "query",
|
|
73
|
+
"hire", "fire", "resign",
|
|
74
|
+
# --------------------------------
|
|
75
|
+
"server", "client", "terminal", "local", "remote",
|
|
76
|
+
"barrack", "cache", "transceiver",
|
|
77
|
+
"ans", "facebook", "store", "messenger",
|
|
78
|
+
"root", "supervisor",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
@abstractmethod
|
|
82
|
+
def is_reserved(self, name: str) -> bool:
|
|
83
|
+
# return name in self.KEYWORDS
|
|
84
|
+
raise NotImplemented
|
|
85
|
+
|
|
86
|
+
@abstractmethod
|
|
87
|
+
def identifier(self, name: str) -> Optional[ID]:
|
|
88
|
+
""" Get ID by short name """
|
|
89
|
+
raise NotImplemented
|
|
90
|
+
|
|
91
|
+
@abstractmethod
|
|
92
|
+
def names(self, identifier: ID) -> List[str]:
|
|
93
|
+
""" Get all short names mapping to the same ID """
|
|
94
|
+
raise NotImplemented
|
|
38
95
|
|
|
39
96
|
|
|
40
97
|
class AddressNameServer(AddressNameService):
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# DIM-SDK : Decentralized Instant Messaging Software Development Kit
|
|
4
|
+
#
|
|
5
|
+
# Written in 2023 by Moky <albert.moky@gmail.com>
|
|
6
|
+
#
|
|
7
|
+
# ==============================================================================
|
|
8
|
+
# MIT License
|
|
9
|
+
#
|
|
10
|
+
# Copyright (c) 2023 Albert Moky
|
|
11
|
+
#
|
|
12
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
# in the Software without restriction, including without limitation the rights
|
|
15
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
# furnished to do so, subject to the following conditions:
|
|
18
|
+
#
|
|
19
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
# copies or substantial portions of the Software.
|
|
21
|
+
#
|
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
# SOFTWARE.
|
|
29
|
+
# ==============================================================================
|
|
30
|
+
|
|
31
|
+
import weakref
|
|
32
|
+
from typing import List, Optional
|
|
33
|
+
|
|
34
|
+
from dimsdk import ID
|
|
35
|
+
from dimsdk import User, Group
|
|
36
|
+
from dimsdk import Facebook
|
|
37
|
+
from dimsdk import Barrack
|
|
38
|
+
|
|
39
|
+
from ..utils import Logging
|
|
40
|
+
from ..utils import ThanosCache
|
|
41
|
+
|
|
42
|
+
from .dbi import AccountDBI
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CommonArchivist(Barrack, Logging):
|
|
46
|
+
|
|
47
|
+
def __init__(self, facebook: Facebook, database: AccountDBI):
|
|
48
|
+
super().__init__()
|
|
49
|
+
self.__barrack = weakref.ref(facebook)
|
|
50
|
+
self.__database = database
|
|
51
|
+
# memory caches
|
|
52
|
+
self.__user_cache = ThanosCache() # ID -> User
|
|
53
|
+
self.__group_cache = ThanosCache() # ID -> Group
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def facebook(self) -> Optional[Facebook]:
|
|
57
|
+
return self.__barrack()
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def database(self) -> AccountDBI:
|
|
61
|
+
return self.__database
|
|
62
|
+
|
|
63
|
+
def reduce_memory(self):
|
|
64
|
+
cnt1 = self.__user_cache.reduce_memory()
|
|
65
|
+
cnt2 = self.__group_cache.reduce_memory()
|
|
66
|
+
return cnt1 + cnt2
|
|
67
|
+
|
|
68
|
+
#
|
|
69
|
+
# Barrack
|
|
70
|
+
#
|
|
71
|
+
|
|
72
|
+
# Override
|
|
73
|
+
def cache_user(self, user: User):
|
|
74
|
+
if user.data_source is None:
|
|
75
|
+
user.data_source = self.facebook
|
|
76
|
+
self.__user_cache.put(key=user.identifier, value=user)
|
|
77
|
+
|
|
78
|
+
# Override
|
|
79
|
+
def cache_group(self, group: Group):
|
|
80
|
+
if group.data_source is None:
|
|
81
|
+
group.data_source = self.facebook
|
|
82
|
+
self.__group_cache.put(key=group.identifier, value=group)
|
|
83
|
+
|
|
84
|
+
# Override
|
|
85
|
+
def get_user(self, identifier: ID):
|
|
86
|
+
return self.__user_cache.get(key=identifier)
|
|
87
|
+
|
|
88
|
+
# Override
|
|
89
|
+
def get_group(self, identifier: ID):
|
|
90
|
+
return self.__group_cache.get(key=identifier)
|
|
91
|
+
|
|
92
|
+
@property # Override
|
|
93
|
+
async def local_users(self) -> List[User]:
|
|
94
|
+
facebook = self.facebook
|
|
95
|
+
array = await self.database.get_local_users()
|
|
96
|
+
if facebook is None or array is None:
|
|
97
|
+
return []
|
|
98
|
+
all_users = []
|
|
99
|
+
for item in array:
|
|
100
|
+
# assert await facebook.private_key_for_signature(identifier=item) is not None
|
|
101
|
+
user = await facebook.get_user(identifier=item)
|
|
102
|
+
if user is not None:
|
|
103
|
+
all_users.append(user)
|
|
104
|
+
else:
|
|
105
|
+
assert False, 'failed to create user: %s' % item
|
|
106
|
+
return all_users
|
|
@@ -41,7 +41,7 @@ from .meta import CompatibleMetaFactory
|
|
|
41
41
|
from .loader import CommonLoader
|
|
42
42
|
from .loader import CommonPluginLoader
|
|
43
43
|
|
|
44
|
-
from .compatible import Compatible
|
|
44
|
+
from .compatible import Compatible, CompatibleIncoming, CompatibleOutgoing
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
__all__ = [
|
|
@@ -59,6 +59,6 @@ __all__ = [
|
|
|
59
59
|
'CommonLoader',
|
|
60
60
|
'CommonPluginLoader',
|
|
61
61
|
|
|
62
|
-
'Compatible',
|
|
62
|
+
'Compatible', 'CompatibleIncoming', 'CompatibleOutgoing',
|
|
63
63
|
|
|
64
64
|
]
|
|
@@ -30,13 +30,14 @@
|
|
|
30
30
|
|
|
31
31
|
from typing import Optional
|
|
32
32
|
|
|
33
|
-
from dimsdk.core import thanos
|
|
34
33
|
from dimsdk import ConstantString
|
|
35
34
|
from dimsdk import EntityType
|
|
36
35
|
from dimsdk import Address, ANYWHERE, EVERYWHERE
|
|
37
36
|
from dimplugins import BTCAddress, ETHAddress
|
|
38
37
|
from dimplugins import BaseAddressFactory
|
|
39
38
|
|
|
39
|
+
from ...utils.thanos import thanos
|
|
40
|
+
|
|
40
41
|
|
|
41
42
|
class CompatibleAddressFactory(BaseAddressFactory):
|
|
42
43
|
|