dimples 1.5.0__tar.gz → 1.5.2__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.5.0 → dimples-1.5.2}/PKG-INFO +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/__init__.py +0 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/__init__.py +4 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/group.py +6 -6
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_invite.py +2 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_query.py +4 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_quit.py +4 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_reset.py +6 -6
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_resign.py +2 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/facebook.py +11 -7
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/messenger.py +2 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/network/session.py +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/packer.py +3 -3
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/processor.py +3 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/__init__.py +0 -2
- dimples-1.5.2/dimples/common/archivist.py +223 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/checker.py +5 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/__init__.py +6 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/compatible.py +49 -30
- dimples-1.5.2/dimples/common/compat/compressor.py +68 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/loader.py +15 -15
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/dbi/session.py +24 -16
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/facebook.py +39 -148
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/messenger.py +14 -44
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/packer.py +30 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/__init__.py +0 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/ans.py +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/handshake.py +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/login.py +8 -8
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/report.py +2 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/document.py +5 -3
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/station.py +2 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/document.py +0 -4
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/station.py +2 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/edge/shared.py +4 -3
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/delegate.py +2 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/register/shared.py +2 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/document.py +4 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/login.py +6 -3
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/report.py +2 -2
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/deliver.py +4 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/messenger.py +4 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/processor.py +4 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/session.py +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/trace.py +14 -7
- {dimples-1.5.0 → dimples-1.5.2}/dimples/station/shared.py +4 -3
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/__init__.py +3 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/config.py +9 -9
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/thanos.py +4 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples.egg-info/PKG-INFO +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples.egg-info/SOURCES.txt +1 -1
- {dimples-1.5.0 → dimples-1.5.2}/dimples.egg-info/requires.txt +2 -3
- {dimples-1.5.0 → dimples-1.5.2}/setup.py +6 -6
- dimples-1.5.0/dimples/common/archivist.py +0 -106
- dimples-1.5.0/dimples/common/protocol/group.py +0 -96
- {dimples-1.5.0 → dimples-1.5.2}/LICENSE +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/README.md +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/checker.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/checkpoint.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/commands.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/creator.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/customized.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_expel.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/grp_join.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/cpu/handshake.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/network/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/network/state.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/network/transition.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/client/terminal.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/anonymous.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/ans.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/address.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/entity.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/meta.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/compat/network.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/dbi/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/dbi/account.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/dbi/message.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/processer.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/block.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/customized.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/mute.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/password.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/roles.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/utils.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/protocol/version.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/queue.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/register.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/common/session.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/flexible.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/gate.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/gatekeeper.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/mars.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/mtp.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/protocol/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/protocol/mars.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/protocol/ws.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/queue.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/seeker.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/session.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/conn/ws.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/account.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/base.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/group.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/group_history.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/group_keys.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/login.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/meta.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/private.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/dos/user.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/message.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/base.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/group.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/grp_history.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/grp_keys.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/login.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/message.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/meta.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/redis/user.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/session.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_base.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_cipherkey.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_document.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_group.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_group_history.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_group_keys.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_login.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_message.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_meta.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_private.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_station.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/database/t_user.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/edge/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/edge/messenger.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/edge/octopus.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/edge/start.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/emitter.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/admin.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/builder.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/emitter.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/helper.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/manager.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/packer.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/group/shared.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/register/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/register/base.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/register/ext.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/register/run.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/checker.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/ans.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/creator.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/cpu/handshake.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/dis_roamer.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/dispatcher.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/facebook.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/packer.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/push.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/server/session_center.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/station/__init__.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/station/handler.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/station/start.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/cache.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/checker.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/http.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples/utils/log.py +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples.egg-info/dependency_links.txt +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples.egg-info/entry_points.txt +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/dimples.egg-info/top_level.txt +0 -0
- {dimples-1.5.0 → dimples-1.5.2}/setup.cfg +0 -0
|
@@ -35,7 +35,9 @@ from .network import SessionState
|
|
|
35
35
|
from .checkpoint import Checkpoint
|
|
36
36
|
from .checker import ClientChecker
|
|
37
37
|
|
|
38
|
+
from .facebook import ClientArchivist
|
|
38
39
|
from .facebook import ClientFacebook
|
|
40
|
+
|
|
39
41
|
from .messenger import ClientMessenger
|
|
40
42
|
from .packer import ClientMessagePacker
|
|
41
43
|
from .processor import ClientMessageProcessor
|
|
@@ -58,7 +60,9 @@ __all__ = [
|
|
|
58
60
|
'Checkpoint',
|
|
59
61
|
'ClientChecker',
|
|
60
62
|
|
|
63
|
+
'ClientArchivist',
|
|
61
64
|
'ClientFacebook',
|
|
65
|
+
|
|
62
66
|
'ClientMessenger',
|
|
63
67
|
'ClientMessagePacker',
|
|
64
68
|
'ClientMessageProcessor',
|
|
@@ -169,10 +169,10 @@ class GroupCommandProcessor(HistoryCommandProcessor):
|
|
|
169
169
|
if expired:
|
|
170
170
|
text = 'Command expired.'
|
|
171
171
|
errors = self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
172
|
-
'template': 'Group command expired: ${cmd}, group: ${
|
|
172
|
+
'template': 'Group command expired: ${cmd}, group: ${gid}.',
|
|
173
173
|
'replacements': {
|
|
174
174
|
'cmd': content.cmd,
|
|
175
|
-
'
|
|
175
|
+
'gid': str(group),
|
|
176
176
|
}
|
|
177
177
|
})
|
|
178
178
|
group = None
|
|
@@ -189,9 +189,9 @@ class GroupCommandProcessor(HistoryCommandProcessor):
|
|
|
189
189
|
if len(members) == 0:
|
|
190
190
|
text = 'Command error.'
|
|
191
191
|
errors = self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
192
|
-
'template': 'Group members empty: ${
|
|
192
|
+
'template': 'Group members empty: ${gid}.',
|
|
193
193
|
'replacements': {
|
|
194
|
-
'
|
|
194
|
+
'gid': str(group),
|
|
195
195
|
}
|
|
196
196
|
})
|
|
197
197
|
else:
|
|
@@ -209,9 +209,9 @@ class GroupCommandProcessor(HistoryCommandProcessor):
|
|
|
209
209
|
# TODO: query group members?
|
|
210
210
|
text = 'Group empty.'
|
|
211
211
|
errors = self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
212
|
-
'template': 'Group empty: ${
|
|
212
|
+
'template': 'Group empty: ${gid}.',
|
|
213
213
|
'replacements': {
|
|
214
|
-
'
|
|
214
|
+
'gid': str(group),
|
|
215
215
|
}
|
|
216
216
|
})
|
|
217
217
|
else:
|
|
@@ -83,9 +83,9 @@ class InviteCommandProcessor(GroupCommandProcessor):
|
|
|
83
83
|
if not is_member:
|
|
84
84
|
text = 'Permission denied.'
|
|
85
85
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
86
|
-
'template': 'Not allowed to invite member into group: ${
|
|
86
|
+
'template': 'Not allowed to invite member into group: ${gid}',
|
|
87
87
|
'replacements': {
|
|
88
|
-
'
|
|
88
|
+
'gid': str(group),
|
|
89
89
|
}
|
|
90
90
|
})
|
|
91
91
|
|
|
@@ -72,9 +72,9 @@ class QueryCommandProcessor(GroupCommandProcessor):
|
|
|
72
72
|
if not can_query:
|
|
73
73
|
text = 'Permission denied.'
|
|
74
74
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
75
|
-
'template': 'Not allowed to query members of group: ${
|
|
75
|
+
'template': 'Not allowed to query members of group: ${gid}',
|
|
76
76
|
'replacements': {
|
|
77
|
-
'
|
|
77
|
+
'gid': str(group),
|
|
78
78
|
}
|
|
79
79
|
})
|
|
80
80
|
|
|
@@ -90,9 +90,9 @@ class QueryCommandProcessor(GroupCommandProcessor):
|
|
|
90
90
|
# group history not updated
|
|
91
91
|
text = 'Group history not updated.'
|
|
92
92
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
93
|
-
'template': 'Group history not updated: ${
|
|
93
|
+
'template': 'Group history not updated: ${gid}, last time: ${time}',
|
|
94
94
|
'replacements': {
|
|
95
|
-
'
|
|
95
|
+
'gid': str(group),
|
|
96
96
|
'time': last_time.timestamp,
|
|
97
97
|
}
|
|
98
98
|
})
|
|
@@ -72,17 +72,17 @@ class QuitCommandProcessor(GroupCommandProcessor):
|
|
|
72
72
|
if is_owner:
|
|
73
73
|
text = 'Permission denied.'
|
|
74
74
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
75
|
-
'template': 'Owner cannot quit from group: ${
|
|
75
|
+
'template': 'Owner cannot quit from group: ${gid}',
|
|
76
76
|
'replacements': {
|
|
77
|
-
'
|
|
77
|
+
'gid': str(group),
|
|
78
78
|
}
|
|
79
79
|
})
|
|
80
80
|
if is_admin:
|
|
81
81
|
text = 'Permission denied.'
|
|
82
82
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
83
|
-
'template': 'Administrator cannot quit from group: ${
|
|
83
|
+
'template': 'Administrator cannot quit from group: ${gid}',
|
|
84
84
|
'replacements': {
|
|
85
|
-
'
|
|
85
|
+
'gid': str(group),
|
|
86
86
|
}
|
|
87
87
|
})
|
|
88
88
|
if is_member:
|
|
@@ -77,18 +77,18 @@ class ResetCommandProcessor(GroupCommandProcessor):
|
|
|
77
77
|
if not can_reset:
|
|
78
78
|
text = 'Permission denied.'
|
|
79
79
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
80
|
-
'template': 'Not allowed to reset members of group: ${
|
|
80
|
+
'template': 'Not allowed to reset members of group: ${gid}',
|
|
81
81
|
'replacements': {
|
|
82
|
-
'
|
|
82
|
+
'gid': str(group),
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
# 2.1. check owner
|
|
86
86
|
if owner != new_members[0]:
|
|
87
87
|
text = 'Permission denied.'
|
|
88
88
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
89
|
-
'template': 'Owner must be the first member of group: ${
|
|
89
|
+
'template': 'Owner must be the first member of group: ${gid}',
|
|
90
90
|
'replacements': {
|
|
91
|
-
'
|
|
91
|
+
'gid': str(group),
|
|
92
92
|
}
|
|
93
93
|
})
|
|
94
94
|
# 2.2. check admins
|
|
@@ -100,9 +100,9 @@ class ResetCommandProcessor(GroupCommandProcessor):
|
|
|
100
100
|
if expel_admin:
|
|
101
101
|
text = 'Permission denied.'
|
|
102
102
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
103
|
-
'template': 'Not allowed to expel administrator of group: ${
|
|
103
|
+
'template': 'Not allowed to expel administrator of group: ${gid}',
|
|
104
104
|
'replacements': {
|
|
105
|
-
'
|
|
105
|
+
'gid': str(group),
|
|
106
106
|
}
|
|
107
107
|
})
|
|
108
108
|
|
|
@@ -71,9 +71,9 @@ class ResignCommandProcessor(GroupCommandProcessor):
|
|
|
71
71
|
if is_owner:
|
|
72
72
|
text = 'Permission denied.'
|
|
73
73
|
return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
|
|
74
|
-
'template': 'Owner cannot resign from group: ${
|
|
74
|
+
'template': 'Owner cannot resign from group: ${gid}',
|
|
75
75
|
'replacements': {
|
|
76
|
-
'
|
|
76
|
+
'gid': str(group),
|
|
77
77
|
}
|
|
78
78
|
})
|
|
79
79
|
if is_admin:
|
|
@@ -39,17 +39,16 @@ from dimsdk import Group
|
|
|
39
39
|
from ..utils import Runner
|
|
40
40
|
from ..common import BroadcastUtils
|
|
41
41
|
from ..common import CommonFacebook
|
|
42
|
+
from ..common import CommonArchivist
|
|
42
43
|
from ..group import SharedGroupManager
|
|
43
44
|
|
|
44
45
|
|
|
45
|
-
class
|
|
46
|
+
class ClientArchivist(CommonArchivist):
|
|
46
47
|
|
|
47
48
|
# Override
|
|
48
|
-
|
|
49
|
-
group =
|
|
50
|
-
|
|
51
|
-
group.data_source = SharedGroupManager()
|
|
52
|
-
return group
|
|
49
|
+
def cache_group(self, group: Group):
|
|
50
|
+
group.data_source = SharedGroupManager()
|
|
51
|
+
super().cache_group(group=group)
|
|
53
52
|
|
|
54
53
|
# Override
|
|
55
54
|
async def save_document(self, document: Document) -> bool:
|
|
@@ -61,9 +60,14 @@ class ClientFacebook(CommonFacebook):
|
|
|
61
60
|
group = document.identifier
|
|
62
61
|
assert group.is_group, 'group ID error: %s' % group
|
|
63
62
|
admins = ID.convert(array=array)
|
|
64
|
-
|
|
63
|
+
db = self.database
|
|
64
|
+
ok = await db.save_administrators(administrators=admins, group=group)
|
|
65
65
|
return ok
|
|
66
66
|
|
|
67
|
+
|
|
68
|
+
class ClientFacebook(CommonFacebook):
|
|
69
|
+
""" Client Facebook with Address Name Service """
|
|
70
|
+
|
|
67
71
|
#
|
|
68
72
|
# Group DataSource
|
|
69
73
|
#
|
|
@@ -167,6 +167,7 @@ class ClientMessenger(CommonMessenger):
|
|
|
167
167
|
|
|
168
168
|
async def _update_visa(self) -> Optional[Visa]:
|
|
169
169
|
facebook = self.facebook
|
|
170
|
+
archivist = facebook.archivist
|
|
170
171
|
user = await facebook.current_user
|
|
171
172
|
assert user is not None, 'current user not found'
|
|
172
173
|
# 1. get sign key for current user
|
|
@@ -189,7 +190,7 @@ class ClientMessenger(CommonMessenger):
|
|
|
189
190
|
})
|
|
190
191
|
if visa.sign(private_key=pri_key) is None:
|
|
191
192
|
self.error(msg='failed to sign visa: %s, private key: %s' % (visa, pri_key))
|
|
192
|
-
elif await
|
|
193
|
+
elif await archivist.save_document(document=visa):
|
|
193
194
|
self.info(msg='visa updated: %s' % visa)
|
|
194
195
|
return visa
|
|
195
196
|
else:
|
|
@@ -61,7 +61,7 @@ class ClientSession(BaseSession):
|
|
|
61
61
|
A random string generated by station.
|
|
62
62
|
It will be set after handshake success.
|
|
63
63
|
|
|
64
|
-
'
|
|
64
|
+
'did' - Local User ID
|
|
65
65
|
It will be set before connecting to remote station.
|
|
66
66
|
When it's empty, the session state would be 'Default'.
|
|
67
67
|
|
|
@@ -73,7 +73,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
73
73
|
'message': 'group not ready',
|
|
74
74
|
'group': str(receiver),
|
|
75
75
|
}
|
|
76
|
-
self.
|
|
76
|
+
self.suspend_instant_message(msg=msg, error=error)
|
|
77
77
|
return False
|
|
78
78
|
#
|
|
79
79
|
# check group members' visa key
|
|
@@ -92,7 +92,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
92
92
|
'group': str(receiver),
|
|
93
93
|
'members': ID.revert(identifiers=waiting),
|
|
94
94
|
}
|
|
95
|
-
self.
|
|
95
|
+
self.suspend_instant_message(msg=msg, error=error)
|
|
96
96
|
# perhaps some members have already disappeared,
|
|
97
97
|
# although the packer will query document when the member's visa key is not found,
|
|
98
98
|
# but the station will never respond with the right document,
|
|
@@ -129,7 +129,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
129
129
|
'message': 'group not ready',
|
|
130
130
|
'group': str(receiver),
|
|
131
131
|
}
|
|
132
|
-
self.
|
|
132
|
+
self.suspend_reliable_message(msg=msg, error=error) # msg['error'] = error
|
|
133
133
|
return False
|
|
134
134
|
|
|
135
135
|
# Override
|
|
@@ -114,11 +114,10 @@ class ClientMessageProcessor(CommonMessageProcessor):
|
|
|
114
114
|
return responses
|
|
115
115
|
sender = r_msg.sender
|
|
116
116
|
receiver = r_msg.receiver
|
|
117
|
-
|
|
118
|
-
if
|
|
117
|
+
me = await self.facebook.select_local_user(receiver=receiver)
|
|
118
|
+
if me is None:
|
|
119
119
|
# assert False, 'receiver error: %s' % receiver
|
|
120
120
|
return responses
|
|
121
|
-
receiver = user.identifier
|
|
122
121
|
messenger = self.messenger
|
|
123
122
|
# check responses
|
|
124
123
|
from_bots = sender.type == EntityType.STATION or sender.type == EntityType.BOT
|
|
@@ -137,6 +136,6 @@ class ClientMessageProcessor(CommonMessageProcessor):
|
|
|
137
136
|
self.info(msg='drop text to %s, origin time=[%s], text=%s' % (sender, r_msg.time, res.text))
|
|
138
137
|
continue
|
|
139
138
|
# normal response
|
|
140
|
-
await messenger.send_content(sender=
|
|
139
|
+
await messenger.send_content(sender=me, receiver=sender, content=res, priority=1)
|
|
141
140
|
# DON'T respond to station directly
|
|
142
141
|
return []
|
|
@@ -0,0 +1,223 @@
|
|
|
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 Optional, List
|
|
33
|
+
|
|
34
|
+
from dimsdk import DateTime
|
|
35
|
+
from dimsdk import VerifyKey, EncryptKey
|
|
36
|
+
from dimsdk import ID, Meta, Document
|
|
37
|
+
from dimsdk import MetaUtils, DocumentUtils
|
|
38
|
+
from dimsdk import User, Group
|
|
39
|
+
from dimsdk import Facebook
|
|
40
|
+
from dimsdk import Archivist
|
|
41
|
+
from dimsdk import Barrack
|
|
42
|
+
|
|
43
|
+
from ..utils import Logging
|
|
44
|
+
from ..utils import MemoryCache, ThanosCache
|
|
45
|
+
|
|
46
|
+
from .dbi import AccountDBI
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class CommonArchivist(Barrack, Archivist, Logging):
|
|
50
|
+
|
|
51
|
+
def __init__(self, facebook: Facebook, database: AccountDBI):
|
|
52
|
+
super().__init__()
|
|
53
|
+
self.__facebook = weakref.ref(facebook)
|
|
54
|
+
self.__database = database
|
|
55
|
+
# memory caches
|
|
56
|
+
self.__user_cache = self._create_user_cache()
|
|
57
|
+
self.__group_cache = self._create_group_cache()
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def facebook(self) -> Optional[Facebook]:
|
|
61
|
+
return self.__facebook()
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def database(self) -> AccountDBI:
|
|
65
|
+
return self.__database
|
|
66
|
+
|
|
67
|
+
# noinspection PyMethodMayBeStatic
|
|
68
|
+
def _create_user_cache(self) -> MemoryCache[ID, User]:
|
|
69
|
+
return ThanosCache()
|
|
70
|
+
|
|
71
|
+
# noinspection PyMethodMayBeStatic
|
|
72
|
+
def _create_group_cache(self) -> MemoryCache[ID, Group]:
|
|
73
|
+
return ThanosCache()
|
|
74
|
+
|
|
75
|
+
def reduce_memory(self):
|
|
76
|
+
"""
|
|
77
|
+
Call it when received 'UIApplicationDidReceiveMemoryWarningNotification',
|
|
78
|
+
this will remove 50% of cached objects
|
|
79
|
+
|
|
80
|
+
:return: number of survivors
|
|
81
|
+
"""
|
|
82
|
+
cnt1 = self.__user_cache.reduce_memory()
|
|
83
|
+
cnt2 = self.__group_cache.reduce_memory()
|
|
84
|
+
return cnt1 + cnt2
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Barrack
|
|
88
|
+
#
|
|
89
|
+
|
|
90
|
+
# Override
|
|
91
|
+
def cache_user(self, user: User):
|
|
92
|
+
if user.data_source is None:
|
|
93
|
+
user.data_source = self.facebook
|
|
94
|
+
self.__user_cache.put(key=user.identifier, value=user)
|
|
95
|
+
|
|
96
|
+
# Override
|
|
97
|
+
def cache_group(self, group: Group):
|
|
98
|
+
if group.data_source is None:
|
|
99
|
+
group.data_source = self.facebook
|
|
100
|
+
self.__group_cache.put(key=group.identifier, value=group)
|
|
101
|
+
|
|
102
|
+
# Override
|
|
103
|
+
def get_user(self, identifier: ID):
|
|
104
|
+
return self.__user_cache.get(key=identifier)
|
|
105
|
+
|
|
106
|
+
# Override
|
|
107
|
+
def get_group(self, identifier: ID):
|
|
108
|
+
return self.__group_cache.get(key=identifier)
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Archivist
|
|
112
|
+
#
|
|
113
|
+
|
|
114
|
+
# Override
|
|
115
|
+
async def save_meta(self, meta: Meta, identifier: ID) -> bool:
|
|
116
|
+
#
|
|
117
|
+
# 1. check valid
|
|
118
|
+
#
|
|
119
|
+
if not self.check_meta(meta=meta, identifier=identifier):
|
|
120
|
+
self.warning(msg='meta not valid: %s' % identifier)
|
|
121
|
+
return False
|
|
122
|
+
#
|
|
123
|
+
# 2. check duplicated
|
|
124
|
+
#
|
|
125
|
+
old = await self.facebook.get_meta(identifier=identifier)
|
|
126
|
+
if old is not None:
|
|
127
|
+
self.debug(msg='meta duplicated: %s' % identifier)
|
|
128
|
+
return True
|
|
129
|
+
#
|
|
130
|
+
# 3. save into database
|
|
131
|
+
#
|
|
132
|
+
db = self.database
|
|
133
|
+
return await db.save_meta(meta=meta, identifier=identifier)
|
|
134
|
+
|
|
135
|
+
# protected
|
|
136
|
+
def check_meta(self, meta: Meta, identifier: ID) -> bool:
|
|
137
|
+
if meta.valid:
|
|
138
|
+
return MetaUtils.match_identifier(identifier=identifier, meta=meta)
|
|
139
|
+
else:
|
|
140
|
+
self.warning(msg='meta error: %s -> %s' % (meta, identifier))
|
|
141
|
+
|
|
142
|
+
# Override
|
|
143
|
+
async def save_document(self, document: Document) -> bool:
|
|
144
|
+
#
|
|
145
|
+
# 1. check valid
|
|
146
|
+
#
|
|
147
|
+
valid = await self.check_document(document=document)
|
|
148
|
+
if not valid:
|
|
149
|
+
self.warning(msg='meta not valid: %s' % document.identifier)
|
|
150
|
+
return False
|
|
151
|
+
#
|
|
152
|
+
# 2. check expired
|
|
153
|
+
#
|
|
154
|
+
expired = await self.is_document_expired(document=document)
|
|
155
|
+
if expired:
|
|
156
|
+
self.info(msg='drop expired document: %s' % document)
|
|
157
|
+
return False
|
|
158
|
+
#
|
|
159
|
+
# 3. save into database
|
|
160
|
+
#
|
|
161
|
+
db = self.database
|
|
162
|
+
return await db.save_document(document=document)
|
|
163
|
+
|
|
164
|
+
# protected
|
|
165
|
+
async def check_document(self, document: Document) -> bool:
|
|
166
|
+
identifier = document.identifier
|
|
167
|
+
doc_time = document.time
|
|
168
|
+
# check document time
|
|
169
|
+
if doc_time is None:
|
|
170
|
+
self.warning(msg='document without time: %s' % identifier)
|
|
171
|
+
else:
|
|
172
|
+
# calibrate the clock
|
|
173
|
+
# make sure the document time is not in the far future
|
|
174
|
+
near_future = DateTime.current_timestamp() + 30 * 60
|
|
175
|
+
if doc_time > near_future:
|
|
176
|
+
self.error(msg='document time error: %s, %s' % (doc_time, identifier))
|
|
177
|
+
return False
|
|
178
|
+
# check valid
|
|
179
|
+
return await self.verify_document(document=document)
|
|
180
|
+
|
|
181
|
+
# protected
|
|
182
|
+
async def verify_document(self, document: Document) -> bool:
|
|
183
|
+
if document.valid:
|
|
184
|
+
return True
|
|
185
|
+
else:
|
|
186
|
+
identifier = document.identifier
|
|
187
|
+
meta = await self.facebook.get_meta(identifier=identifier)
|
|
188
|
+
if meta is None:
|
|
189
|
+
self.warning(msg='failed to get meta: %s' % identifier)
|
|
190
|
+
else:
|
|
191
|
+
return document.verify(public_key=meta.public_key)
|
|
192
|
+
|
|
193
|
+
# protected
|
|
194
|
+
async def is_document_expired(self, document: Document) -> bool:
|
|
195
|
+
identifier = document.identifier
|
|
196
|
+
doc_type = DocumentUtils.get_document_type(document=document)
|
|
197
|
+
if doc_type is None:
|
|
198
|
+
doc_type = '*'
|
|
199
|
+
# check old documents with type
|
|
200
|
+
docs = await self.facebook.get_documents(identifier=identifier)
|
|
201
|
+
if docs is None or len(docs) == 0:
|
|
202
|
+
return False
|
|
203
|
+
old = DocumentUtils.last_document(documents=docs, doc_type=doc_type)
|
|
204
|
+
return old is not None and DocumentUtils.is_expired(this_doc=document, old_doc=old)
|
|
205
|
+
|
|
206
|
+
# Override
|
|
207
|
+
async def get_meta_key(self, identifier: ID) -> Optional[VerifyKey]:
|
|
208
|
+
meta = await self.facebook.get_meta(identifier=identifier)
|
|
209
|
+
if meta is not None:
|
|
210
|
+
return meta.public_key
|
|
211
|
+
|
|
212
|
+
# Override
|
|
213
|
+
async def get_visa_key(self, identifier: ID) -> Optional[EncryptKey]:
|
|
214
|
+
docs = await self.facebook.get_documents(identifier=identifier)
|
|
215
|
+
if docs is None or len(docs) == 0:
|
|
216
|
+
return None
|
|
217
|
+
visa = DocumentUtils.last_visa(documents=docs)
|
|
218
|
+
if visa is not None:
|
|
219
|
+
return visa.public_key
|
|
220
|
+
|
|
221
|
+
# Override
|
|
222
|
+
async def local_users(self) -> List[ID]:
|
|
223
|
+
return await self.database.get_local_users()
|
|
@@ -34,12 +34,13 @@ from typing import Optional, List, Dict
|
|
|
34
34
|
from dimsdk import DateTime
|
|
35
35
|
from dimsdk import ID, Meta, Document, Visa
|
|
36
36
|
|
|
37
|
+
from ..utils import Logging
|
|
37
38
|
from ..utils import FrequencyChecker, RecentTimeChecker
|
|
38
39
|
|
|
39
40
|
from .dbi import AccountDBI
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
class EntityChecker(ABC):
|
|
43
|
+
class EntityChecker(Logging, ABC):
|
|
43
44
|
|
|
44
45
|
# each query will be expired after 10 minutes
|
|
45
46
|
QUERY_EXPIRES = 10 * 60
|
|
@@ -174,7 +175,7 @@ class EntityChecker(ABC):
|
|
|
174
175
|
doc_time = doc.time
|
|
175
176
|
if doc_time is None:
|
|
176
177
|
# assert False, 'document error: %s' % doc
|
|
177
|
-
|
|
178
|
+
self.warning(msg='document time error: %s' % doc)
|
|
178
179
|
elif last_time is None or last_time < doc_time:
|
|
179
180
|
last_time = doc_time
|
|
180
181
|
# OK
|
|
@@ -221,8 +222,8 @@ class EntityChecker(ABC):
|
|
|
221
222
|
for cmd, _ in array:
|
|
222
223
|
his_time = cmd.time
|
|
223
224
|
if his_time is None:
|
|
224
|
-
assert False, 'group command error: %s' % cmd
|
|
225
|
-
|
|
225
|
+
# assert False, 'group command error: %s' % cmd
|
|
226
|
+
self.warning(msg='group command time error: %s' % cmd)
|
|
226
227
|
elif last_time is None or last_time < his_time:
|
|
227
228
|
last_time = his_time
|
|
228
229
|
# OK
|
|
@@ -38,9 +38,11 @@ from .address import UnknownAddress
|
|
|
38
38
|
|
|
39
39
|
from .meta import CompatibleMetaFactory
|
|
40
40
|
|
|
41
|
-
from .loader import
|
|
41
|
+
from .loader import CommonExtensionLoader
|
|
42
42
|
from .loader import CommonPluginLoader
|
|
43
|
+
from .loader import LibraryLoader
|
|
43
44
|
|
|
45
|
+
from .compressor import CompatibleCompressor # , CompatibleShortener
|
|
44
46
|
from .compatible import Compatible, CompatibleIncoming, CompatibleOutgoing
|
|
45
47
|
|
|
46
48
|
|
|
@@ -56,9 +58,11 @@ __all__ = [
|
|
|
56
58
|
|
|
57
59
|
'CompatibleMetaFactory',
|
|
58
60
|
|
|
59
|
-
'
|
|
61
|
+
'CommonExtensionLoader',
|
|
60
62
|
'CommonPluginLoader',
|
|
63
|
+
'LibraryLoader',
|
|
61
64
|
|
|
65
|
+
'CompatibleCompressor', # 'CompatibleShortener',
|
|
62
66
|
'Compatible', 'CompatibleIncoming', 'CompatibleOutgoing',
|
|
63
67
|
|
|
64
68
|
]
|