dimples 1.3.5__tar.gz → 1.4.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.0/LICENSE +21 -0
- dimples-1.4.0/PKG-INFO +69 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/__init__.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/packer.py +4 -14
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/__init__.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/messenger.py +16 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/packer.py +10 -23
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/processer.py +2 -58
- dimples-1.4.0/dimples/common/queue.py +86 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/session.py +1 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/__init__.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/account.py +8 -8
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/base.py +48 -23
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/document.py +1 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/group.py +12 -12
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/group_history.py +4 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/group_keys.py +4 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/message.py +5 -5
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/__init__.py +1 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/base.py +12 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/document.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/group.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/grp_history.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/grp_keys.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/login.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/message.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/meta.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/station.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/redis/user.py +2 -2
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/session.py +4 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_base.py +0 -28
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_cipherkey.py +2 -3
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_document.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_group.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_group_history.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_group_keys.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_login.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_message.py +4 -3
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_meta.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_private.py +4 -3
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_station.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/t_user.py +5 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/edge/shared.py +48 -61
- {dimples-1.3.5 → dimples-1.4.0}/dimples/edge/start.py +2 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/register/shared.py +6 -34
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/__init__.py +0 -5
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/checker.py +3 -3
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/messenger.py +3 -6
- dimples-1.4.0/dimples/server/packer.py +74 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/processor.py +90 -55
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/push.py +4 -4
- {dimples-1.3.5 → dimples-1.4.0}/dimples/station/shared.py +45 -59
- {dimples-1.3.5 → dimples-1.4.0}/dimples/station/start.py +2 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples/utils/__init__.py +5 -0
- dimples-1.4.0/dimples/utils/config.py +395 -0
- dimples-1.4.0/dimples/utils/http.py +203 -0
- dimples-1.4.0/dimples.egg-info/PKG-INFO +69 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples.egg-info/SOURCES.txt +3 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples.egg-info/entry_points.txt +0 -1
- {dimples-1.3.5 → dimples-1.4.0}/dimples.egg-info/requires.txt +2 -1
- {dimples-1.3.5 → dimples-1.4.0}/setup.py +4 -2
- dimples-1.3.5/PKG-INFO +0 -69
- dimples-1.3.5/dimples/server/packer.py +0 -247
- dimples-1.3.5/dimples/utils/config.py +0 -226
- dimples-1.3.5/dimples.egg-info/PKG-INFO +0 -69
- {dimples-1.3.5 → dimples-1.4.0}/README.md +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/checker.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/checkpoint.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/commands.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/creator.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/customized.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/group.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_expel.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_invite.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_join.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_query.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_quit.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_reset.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/grp_resign.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/cpu/handshake.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/facebook.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/messenger.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/network/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/network/session.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/network/state.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/network/transition.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/processor.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/client/terminal.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/anonymous.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/ans.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/archivist.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/checker.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/address.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/compatible.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/entity.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/loader.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/meta.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/compat/network.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/dbi/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/dbi/account.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/dbi/message.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/dbi/session.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/facebook.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/ans.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/block.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/customized.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/group.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/handshake.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/login.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/mute.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/password.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/report.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/utils.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/protocol/version.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/register.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/common/session.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/flexible.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/gate.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/gatekeeper.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/mars.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/mtp.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/protocol/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/protocol/mars.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/protocol/ws.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/queue.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/seeker.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/conn/ws.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/login.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/meta.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/private.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/station.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/database/dos/user.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/edge/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/edge/messenger.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/edge/octopus.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/emitter.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/admin.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/builder.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/delegate.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/emitter.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/helper.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/manager.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/packer.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/group/shared.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/register/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/register/base.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/register/ext.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/register/run.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/ans.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/creator.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/document.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/handshake.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/login.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/cpu/report.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/deliver.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/dis_roamer.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/dispatcher.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/facebook.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/session.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/session_center.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/server/trace.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/station/__init__.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/station/handler.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/utils/cache.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/utils/checker.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples/utils/log.py +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples.egg-info/dependency_links.txt +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/dimples.egg-info/top_level.txt +0 -0
- {dimples-1.3.5 → dimples-1.4.0}/setup.cfg +0 -0
dimples-1.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Albert Moky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
dimples-1.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: dimples
|
|
3
|
+
Version: 1.4.0
|
|
4
|
+
Summary: DIMP Library for Edges and Stations
|
|
5
|
+
Home-page: https://github.com/dimchat/demo-py
|
|
6
|
+
Author: Albert Moky
|
|
7
|
+
Author-email: albert.moky@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
|
|
15
|
+
# DIMP Library for Edges and Stations (Python version)
|
|
16
|
+
|
|
17
|
+
[](https://github.com/dimchat/demo-py/blob/master/LICENSE)
|
|
18
|
+
[](https://github.com/dimchat/demo-py/pulls)
|
|
19
|
+
[](https://github.com/dimchat/demo-py/wiki)
|
|
20
|
+
[](https://github.com/dimchat/demo-py/issues)
|
|
21
|
+
[](https://github.com/dimchat/demo-py/archive/refs/heads/main.zip)
|
|
22
|
+
[](https://github.com/dimchat/demo-py/tags)
|
|
23
|
+
[](https://pypi.org/project/dimples)
|
|
24
|
+
|
|
25
|
+
[](https://github.com/dimchat/demo-py/watchers)
|
|
26
|
+
[](https://github.com/dimchat/demo-py/forks)
|
|
27
|
+
[](https://github.com/dimchat/demo-py/stargazers)
|
|
28
|
+
[](https://github.com/orgs/dimchat/followers)
|
|
29
|
+
|
|
30
|
+
## Dependencies
|
|
31
|
+
|
|
32
|
+
* setup.py
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
install_requires=[
|
|
36
|
+
# 'pycryptodome', # 3.14.1
|
|
37
|
+
# 'base58', # 1.0.3
|
|
38
|
+
# 'ecdsa', # 0.16.1
|
|
39
|
+
'dimplugins>=2.2.2',
|
|
40
|
+
|
|
41
|
+
'dimsdk>=2.2.2',
|
|
42
|
+
# 'dimp>=2.2.2',
|
|
43
|
+
# 'dkd>=2.2.2',
|
|
44
|
+
# 'mkm>=2.2.2',
|
|
45
|
+
|
|
46
|
+
'startrek>=2.2.2',
|
|
47
|
+
'tcp>=2.2.2',
|
|
48
|
+
'udp>=2.2.2',
|
|
49
|
+
|
|
50
|
+
'aiou>=0.3.0',
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
* Latest Versions
|
|
55
|
+
|
|
56
|
+
| Name | Version | Description |
|
|
57
|
+
|------|---------|-------------|
|
|
58
|
+
| [Ming Ke Ming (名可名)](https://github.com/dimchat/mkm-py) | [](https://pypi.org/project/mkm) | Decentralized User Identity Authentication |
|
|
59
|
+
| [Dao Ke Dao (道可道)](https://github.com/dimchat/dkd-py) | [](https://pypi.org/project/dkd) | Universal Message Module |
|
|
60
|
+
| [DIMP (去中心化通讯协议)](https://github.com/dimchat/core-py) | [](https://pypi.org/project/dimp) | Decentralized Instant Messaging Protocol |
|
|
61
|
+
| [DIM SDK](https://github.com/dimchat/sdk-py) | [](https://pypi.org/project/dimsdk) | Software Development Kit |
|
|
62
|
+
| [DIM Plugins](https://github.com/dimchat/sdk-dart) | [](https://pypi.org/project/dimplugins) | Cryptography & Account Plugins |
|
|
63
|
+
|
|
64
|
+
Talk is cheap, [read my codes](https://github.com/dimchat/demo-py).
|
|
65
|
+
|
|
66
|
+
----
|
|
67
|
+
|
|
68
|
+
Copyright © 2018-2025 Albert Moky
|
|
69
|
+
[](https://github.com/moky?tab=followers)
|
|
@@ -374,7 +374,7 @@ __all__ = [
|
|
|
374
374
|
'CommonMessenger',
|
|
375
375
|
'CommonMessagePacker',
|
|
376
376
|
'CommonMessageProcessor',
|
|
377
|
-
'
|
|
377
|
+
'SuspendedMessageQueue',
|
|
378
378
|
|
|
379
379
|
'Transmitter',
|
|
380
380
|
'Session',
|
|
@@ -470,7 +470,7 @@ __all__ = [
|
|
|
470
470
|
# Table
|
|
471
471
|
#
|
|
472
472
|
|
|
473
|
-
'
|
|
473
|
+
'DbTask',
|
|
474
474
|
|
|
475
475
|
'PrivateKeyTable', 'MetaTable', 'DocumentTable',
|
|
476
476
|
'UserTable', 'GroupTable', 'GroupHistoryTable',
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
Common extensions for MessagePacker
|
|
28
28
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
29
29
|
"""
|
|
30
|
-
from typing import Optional, List
|
|
30
|
+
from typing import Optional, List
|
|
31
31
|
|
|
32
32
|
from dimsdk import ID
|
|
33
33
|
from dimsdk import ContentType, TextContent, FileContent
|
|
@@ -48,16 +48,6 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
48
48
|
assert isinstance(barrack, CommonFacebook), 'barrack error: %s' % barrack
|
|
49
49
|
return barrack
|
|
50
50
|
|
|
51
|
-
# Override
|
|
52
|
-
def suspend_reliable_message(self, msg: ReliableMessage, error: Dict):
|
|
53
|
-
# TODO:
|
|
54
|
-
self.warning(msg='TODO: suspend reliable message: %s => %s' % (msg.sender, msg.receiver))
|
|
55
|
-
|
|
56
|
-
# Override
|
|
57
|
-
def suspend_instant_message(self, msg: InstantMessage, error: Dict):
|
|
58
|
-
# TODO:
|
|
59
|
-
self.warning(msg='TODO: suspend instant message: %s => %s' % (msg.sender, msg.receiver))
|
|
60
|
-
|
|
61
51
|
# protected
|
|
62
52
|
async def _get_members(self, group: ID) -> List[ID]:
|
|
63
53
|
""" for checking whether group's ready """
|
|
@@ -83,7 +73,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
83
73
|
'message': 'group not ready',
|
|
84
74
|
'group': str(receiver),
|
|
85
75
|
}
|
|
86
|
-
self.suspend_instant_message(msg=msg, error=error)
|
|
76
|
+
self.messenger.suspend_instant_message(msg=msg, error=error)
|
|
87
77
|
return False
|
|
88
78
|
#
|
|
89
79
|
# check group members' visa key
|
|
@@ -102,7 +92,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
102
92
|
'group': str(receiver),
|
|
103
93
|
'members': ID.revert(array=waiting),
|
|
104
94
|
}
|
|
105
|
-
self.suspend_instant_message(msg=msg, error=error)
|
|
95
|
+
self.messenger.suspend_instant_message(msg=msg, error=error)
|
|
106
96
|
# perhaps some members have already disappeared,
|
|
107
97
|
# although the packer will query document when the member's visa key is not found,
|
|
108
98
|
# but the station will never respond with the right document,
|
|
@@ -139,7 +129,7 @@ class ClientMessagePacker(CommonMessagePacker):
|
|
|
139
129
|
'message': 'group not ready',
|
|
140
130
|
'group': str(receiver),
|
|
141
131
|
}
|
|
142
|
-
self.suspend_reliable_message(msg=msg, error=error) # msg['error'] = error
|
|
132
|
+
self.messenger.suspend_reliable_message(msg=msg, error=error) # msg['error'] = error
|
|
143
133
|
return False
|
|
144
134
|
|
|
145
135
|
# Override
|
|
@@ -42,7 +42,7 @@ from .facebook import CommonFacebook
|
|
|
42
42
|
from .messenger import CommonMessenger
|
|
43
43
|
from .packer import CommonMessagePacker
|
|
44
44
|
from .processer import CommonMessageProcessor
|
|
45
|
-
from .
|
|
45
|
+
from .queue import SuspendedMessageQueue
|
|
46
46
|
from .session import Transmitter, Session
|
|
47
47
|
|
|
48
48
|
|
|
@@ -100,7 +100,7 @@ __all__ = [
|
|
|
100
100
|
'CommonMessenger',
|
|
101
101
|
'CommonMessagePacker',
|
|
102
102
|
'CommonMessageProcessor',
|
|
103
|
-
'
|
|
103
|
+
'SuspendedMessageQueue',
|
|
104
104
|
|
|
105
105
|
'Transmitter',
|
|
106
106
|
'Session',
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
38
|
from abc import ABC
|
|
39
|
-
from typing import Optional, Union, Tuple
|
|
39
|
+
from typing import Optional, Union, Tuple, List, Dict
|
|
40
40
|
|
|
41
41
|
from dimsdk import SymmetricKey
|
|
42
42
|
from dimsdk import ID
|
|
@@ -53,6 +53,8 @@ from .dbi import MessageDBI
|
|
|
53
53
|
from .facebook import CommonFacebook
|
|
54
54
|
from .session import Transmitter, Session
|
|
55
55
|
|
|
56
|
+
from .queue import SuspendedMessageQueue
|
|
57
|
+
|
|
56
58
|
from .compat import Compatible
|
|
57
59
|
|
|
58
60
|
|
|
@@ -65,6 +67,7 @@ class CommonMessenger(Messenger, Transmitter, Logging, ABC):
|
|
|
65
67
|
self.__database = database
|
|
66
68
|
self.__packer: Optional[Packer] = None
|
|
67
69
|
self.__processor: Optional[Processor] = None
|
|
70
|
+
self.__queue = SuspendedMessageQueue()
|
|
68
71
|
|
|
69
72
|
@property # Override
|
|
70
73
|
def packer(self) -> Packer:
|
|
@@ -102,6 +105,18 @@ class CommonMessenger(Messenger, Transmitter, Logging, ABC):
|
|
|
102
105
|
def session(self) -> Session:
|
|
103
106
|
return self.__session
|
|
104
107
|
|
|
108
|
+
def suspend_reliable_message(self, msg: ReliableMessage, error: Dict):
|
|
109
|
+
self.__queue.suspend_reliable_message(msg=msg, error=error)
|
|
110
|
+
|
|
111
|
+
def suspend_instant_message(self, msg: InstantMessage, error: Dict):
|
|
112
|
+
self.__queue.suspend_instant_message(msg=msg, error=error)
|
|
113
|
+
|
|
114
|
+
def resume_reliable_messages(self) -> List[ReliableMessage]:
|
|
115
|
+
return self.__queue.resume_reliable_messages()
|
|
116
|
+
|
|
117
|
+
def resume_instant_messages(self) -> List[InstantMessage]:
|
|
118
|
+
return self.__queue.resume_instant_messages()
|
|
119
|
+
|
|
105
120
|
# Override
|
|
106
121
|
async def encrypt_key(self, data: bytes, receiver: ID, msg: InstantMessage) -> Optional[bytes]:
|
|
107
122
|
try:
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
# SOFTWARE.
|
|
24
24
|
# ==============================================================================
|
|
25
25
|
|
|
26
|
-
from abc import ABC
|
|
27
|
-
from typing import Optional
|
|
26
|
+
from abc import ABC
|
|
27
|
+
from typing import Optional
|
|
28
28
|
|
|
29
29
|
from dimsdk import EncryptKey
|
|
30
30
|
from dimsdk import ID
|
|
@@ -34,30 +34,17 @@ from dimsdk import MessageUtils
|
|
|
34
34
|
|
|
35
35
|
from ..utils import Logging
|
|
36
36
|
|
|
37
|
+
from .messenger import CommonMessenger
|
|
37
38
|
from .compat import Compatible
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
class CommonMessagePacker(MessagePacker, Logging, ABC):
|
|
41
42
|
|
|
42
|
-
@
|
|
43
|
-
def
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
:param msg: incoming message
|
|
48
|
-
:param error: error info
|
|
49
|
-
"""
|
|
50
|
-
raise NotImplemented
|
|
51
|
-
|
|
52
|
-
@abstractmethod # protected
|
|
53
|
-
def suspend_instant_message(self, msg: InstantMessage, error: Dict):
|
|
54
|
-
"""
|
|
55
|
-
Add outgo message in a queue for waiting receiver's visa
|
|
56
|
-
|
|
57
|
-
:param msg: outgo message
|
|
58
|
-
:param error: error info
|
|
59
|
-
"""
|
|
60
|
-
raise NotImplemented
|
|
43
|
+
@property
|
|
44
|
+
def messenger(self) -> Optional[CommonMessenger]:
|
|
45
|
+
transceiver = super().messenger
|
|
46
|
+
assert isinstance(transceiver, CommonMessenger), 'transceiver error: %s' % transceiver
|
|
47
|
+
return transceiver
|
|
61
48
|
|
|
62
49
|
#
|
|
63
50
|
# Checking
|
|
@@ -90,7 +77,7 @@ class CommonMessagePacker(MessagePacker, Logging, ABC):
|
|
|
90
77
|
'message': 'verify key not found',
|
|
91
78
|
'user': str(sender),
|
|
92
79
|
}
|
|
93
|
-
self.suspend_reliable_message(msg=msg, error=error) # msg['error'] = error
|
|
80
|
+
self.messenger.suspend_reliable_message(msg=msg, error=error) # msg['error'] = error
|
|
94
81
|
return False
|
|
95
82
|
|
|
96
83
|
# protected
|
|
@@ -115,7 +102,7 @@ class CommonMessagePacker(MessagePacker, Logging, ABC):
|
|
|
115
102
|
'message': 'encrypt key not found',
|
|
116
103
|
'user': str(receiver),
|
|
117
104
|
}
|
|
118
|
-
self.suspend_instant_message(msg=msg, error=error) # msg['error'] = error
|
|
105
|
+
self.messenger.suspend_instant_message(msg=msg, error=error) # msg['error'] = error
|
|
119
106
|
return False
|
|
120
107
|
|
|
121
108
|
#
|
|
@@ -23,13 +23,12 @@
|
|
|
23
23
|
# SOFTWARE.
|
|
24
24
|
# ==============================================================================
|
|
25
25
|
|
|
26
|
-
import threading
|
|
27
26
|
from abc import ABC, abstractmethod
|
|
28
|
-
from typing import List
|
|
27
|
+
from typing import List
|
|
29
28
|
|
|
30
29
|
from dimsdk import DateTime
|
|
31
30
|
from dimsdk import Content
|
|
32
|
-
from dimsdk import
|
|
31
|
+
from dimsdk import ReliableMessage
|
|
33
32
|
from dimsdk import MessageProcessor
|
|
34
33
|
from dimsdk import Facebook, Messenger
|
|
35
34
|
from dimsdk import ContentProcessorCreator
|
|
@@ -83,58 +82,3 @@ class CommonMessageProcessor(MessageProcessor, Logging, ABC):
|
|
|
83
82
|
# to make sure the user info synchronized
|
|
84
83
|
await self._check_visa_time(content=content, r_msg=r_msg)
|
|
85
84
|
return responses
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class Vestibule(Logging):
|
|
89
|
-
"""
|
|
90
|
-
Message Waiting List
|
|
91
|
-
~~~~~~~~~~~~~~~~~~~~
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
def __init__(self, capacity: int = 32):
|
|
95
|
-
super().__init__()
|
|
96
|
-
self.__capacity = capacity
|
|
97
|
-
# suspended messages
|
|
98
|
-
self.__suspend_lock = threading.Lock()
|
|
99
|
-
self.__incoming_messages: List[ReliableMessage] = []
|
|
100
|
-
self.__outgoing_messages: List[InstantMessage] = []
|
|
101
|
-
|
|
102
|
-
def suspend_reliable_message(self, msg: ReliableMessage, error: Dict):
|
|
103
|
-
"""
|
|
104
|
-
Add income message in a queue for waiting sender's visa
|
|
105
|
-
|
|
106
|
-
:param msg: incoming message
|
|
107
|
-
:param error: error info
|
|
108
|
-
"""
|
|
109
|
-
self.warning(msg='suspend message: %s -> %s, %s' % (msg.sender, msg.receiver, error))
|
|
110
|
-
msg['error'] = error
|
|
111
|
-
with self.__suspend_lock:
|
|
112
|
-
if len(self.__incoming_messages) > self.__capacity:
|
|
113
|
-
self.__incoming_messages.pop(0)
|
|
114
|
-
self.__incoming_messages.append(msg)
|
|
115
|
-
|
|
116
|
-
def suspend_instant_message(self, msg: InstantMessage, error: Dict):
|
|
117
|
-
"""
|
|
118
|
-
Add outgo message in a queue for waiting receiver's visa
|
|
119
|
-
|
|
120
|
-
:param msg: outgo message
|
|
121
|
-
:param error: error info
|
|
122
|
-
"""
|
|
123
|
-
self.warning(msg='suspend message: %s -> %s, %s' % (msg.sender, msg.receiver, error))
|
|
124
|
-
msg['error'] = error
|
|
125
|
-
with self.__suspend_lock:
|
|
126
|
-
if len(self.__outgoing_messages) > self.__capacity:
|
|
127
|
-
self.__outgoing_messages.pop(0)
|
|
128
|
-
self.__outgoing_messages.append(msg)
|
|
129
|
-
|
|
130
|
-
def resume_reliable_messages(self) -> List[ReliableMessage]:
|
|
131
|
-
with self.__suspend_lock:
|
|
132
|
-
messages = self.__incoming_messages
|
|
133
|
-
self.__incoming_messages = []
|
|
134
|
-
return messages
|
|
135
|
-
|
|
136
|
-
def resume_instant_messages(self) -> List[InstantMessage]:
|
|
137
|
-
with self.__suspend_lock:
|
|
138
|
-
messages = self.__outgoing_messages
|
|
139
|
-
self.__outgoing_messages = []
|
|
140
|
-
return messages
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# ==============================================================================
|
|
3
|
+
# MIT License
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2023 Albert Moky
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
# ==============================================================================
|
|
25
|
+
|
|
26
|
+
import threading
|
|
27
|
+
from typing import List, Dict
|
|
28
|
+
|
|
29
|
+
from dimsdk import InstantMessage, ReliableMessage
|
|
30
|
+
|
|
31
|
+
from ..utils import Logging
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class SuspendedMessageQueue(Logging):
|
|
35
|
+
"""
|
|
36
|
+
Message Waiting List
|
|
37
|
+
~~~~~~~~~~~~~~~~~~~~
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, capacity: int = 32):
|
|
41
|
+
super().__init__()
|
|
42
|
+
self.__capacity = capacity
|
|
43
|
+
# suspended messages
|
|
44
|
+
self.__suspend_lock = threading.Lock()
|
|
45
|
+
self.__incoming_messages: List[ReliableMessage] = []
|
|
46
|
+
self.__outgoing_messages: List[InstantMessage] = []
|
|
47
|
+
|
|
48
|
+
def suspend_reliable_message(self, msg: ReliableMessage, error: Dict):
|
|
49
|
+
"""
|
|
50
|
+
Add income message in a queue for waiting sender's visa
|
|
51
|
+
|
|
52
|
+
:param msg: incoming message
|
|
53
|
+
:param error: error info
|
|
54
|
+
"""
|
|
55
|
+
self.warning(msg='suspend message: %s -> %s, %s' % (msg.sender, msg.receiver, error))
|
|
56
|
+
msg['error'] = error
|
|
57
|
+
with self.__suspend_lock:
|
|
58
|
+
if len(self.__incoming_messages) > self.__capacity:
|
|
59
|
+
self.__incoming_messages.pop(0)
|
|
60
|
+
self.__incoming_messages.append(msg)
|
|
61
|
+
|
|
62
|
+
def suspend_instant_message(self, msg: InstantMessage, error: Dict):
|
|
63
|
+
"""
|
|
64
|
+
Add outgo message in a queue for waiting receiver's visa
|
|
65
|
+
|
|
66
|
+
:param msg: outgo message
|
|
67
|
+
:param error: error info
|
|
68
|
+
"""
|
|
69
|
+
self.warning(msg='suspend message: %s -> %s, %s' % (msg.sender, msg.receiver, error))
|
|
70
|
+
msg['error'] = error
|
|
71
|
+
with self.__suspend_lock:
|
|
72
|
+
if len(self.__outgoing_messages) > self.__capacity:
|
|
73
|
+
self.__outgoing_messages.pop(0)
|
|
74
|
+
self.__outgoing_messages.append(msg)
|
|
75
|
+
|
|
76
|
+
def resume_reliable_messages(self) -> List[ReliableMessage]:
|
|
77
|
+
with self.__suspend_lock:
|
|
78
|
+
messages = self.__incoming_messages
|
|
79
|
+
self.__incoming_messages = []
|
|
80
|
+
return messages
|
|
81
|
+
|
|
82
|
+
def resume_instant_messages(self) -> List[InstantMessage]:
|
|
83
|
+
with self.__suspend_lock:
|
|
84
|
+
messages = self.__outgoing_messages
|
|
85
|
+
self.__outgoing_messages = []
|
|
86
|
+
return messages
|
|
@@ -58,7 +58,7 @@ class BaseSession(GateKeeper, Session, ABC):
|
|
|
58
58
|
return '<%s id="%s" remote="%s" key="%s" />' % (cname, self.identifier, self.remote_address, self.session_key)
|
|
59
59
|
|
|
60
60
|
# Override
|
|
61
|
-
def __repr__(self):
|
|
61
|
+
def __repr__(self) -> str:
|
|
62
62
|
cname = self.__class__.__name__
|
|
63
63
|
return '<%s id="%s" remote="%s" key="%s" />' % (cname, self.identifier, self.remote_address, self.session_key)
|
|
64
64
|
|
|
@@ -34,7 +34,7 @@ from ..common.dbi import *
|
|
|
34
34
|
from .dos import *
|
|
35
35
|
from .redis import *
|
|
36
36
|
|
|
37
|
-
from .t_base import
|
|
37
|
+
from .t_base import DbTask
|
|
38
38
|
|
|
39
39
|
from .t_private import PrivateKeyTable
|
|
40
40
|
from .t_meta import MetaTable
|
|
@@ -100,7 +100,7 @@ __all__ = [
|
|
|
100
100
|
# Table
|
|
101
101
|
#
|
|
102
102
|
|
|
103
|
-
'
|
|
103
|
+
'DbTask',
|
|
104
104
|
|
|
105
105
|
'PrivateKeyTable', 'MetaTable', 'DocumentTable',
|
|
106
106
|
'UserTable', 'GroupTable', 'GroupHistoryTable',
|
|
@@ -31,9 +31,9 @@ from dimsdk import ID, Meta, Document, Bulletin
|
|
|
31
31
|
from dimsdk import ReliableMessage
|
|
32
32
|
from dimsdk import MetaUtils
|
|
33
33
|
|
|
34
|
+
from ..utils import Config
|
|
34
35
|
from ..common import AccountDBI
|
|
35
36
|
|
|
36
|
-
from .t_base import DbInfo
|
|
37
37
|
from .t_private import PrivateKeyTable
|
|
38
38
|
from .t_meta import MetaTable
|
|
39
39
|
from .t_document import DocumentTable
|
|
@@ -48,14 +48,14 @@ class AccountDatabase(AccountDBI):
|
|
|
48
48
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
49
49
|
"""
|
|
50
50
|
|
|
51
|
-
def __init__(self,
|
|
51
|
+
def __init__(self, config: Config):
|
|
52
52
|
super().__init__()
|
|
53
|
-
self._private_table = PrivateKeyTable(
|
|
54
|
-
self._meta_table = MetaTable(
|
|
55
|
-
self._doc_table = DocumentTable(
|
|
56
|
-
self._user_table = UserTable(
|
|
57
|
-
self._group_table = GroupTable(
|
|
58
|
-
self._history_table = GroupHistoryTable(
|
|
53
|
+
self._private_table = PrivateKeyTable(config=config)
|
|
54
|
+
self._meta_table = MetaTable(config=config)
|
|
55
|
+
self._doc_table = DocumentTable(config=config)
|
|
56
|
+
self._user_table = UserTable(config=config)
|
|
57
|
+
self._group_table = GroupTable(config=config)
|
|
58
|
+
self._history_table = GroupHistoryTable(config=config)
|
|
59
59
|
|
|
60
60
|
def show_info(self):
|
|
61
61
|
self._private_table.show_info()
|
|
@@ -29,16 +29,7 @@ from ...utils import template_replace
|
|
|
29
29
|
from ...utils import Log
|
|
30
30
|
from ...utils import Path
|
|
31
31
|
from ...utils import TextFile, JSONFile
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"""
|
|
35
|
-
Root Directory
|
|
36
|
-
~~~~~~~~~~~~~~
|
|
37
|
-
Directory for MKM database
|
|
38
|
-
"""
|
|
39
|
-
root_dir = '/var/.dim'
|
|
40
|
-
pub_dir = '{ROOT}/public'
|
|
41
|
-
pri_dir = '{ROOT}/private'
|
|
32
|
+
from ...utils import Config
|
|
42
33
|
|
|
43
34
|
|
|
44
35
|
class Storage:
|
|
@@ -47,42 +38,76 @@ class Storage:
|
|
|
47
38
|
~~~~~~~~~~~
|
|
48
39
|
"""
|
|
49
40
|
|
|
50
|
-
def __init__(self,
|
|
41
|
+
def __init__(self, config: Config):
|
|
51
42
|
super().__init__()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
self.__config = config
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def root_dir(self) -> str:
|
|
47
|
+
path = self.__config.database_root
|
|
48
|
+
if path is None:
|
|
49
|
+
path = '/var/.dim'
|
|
50
|
+
return path
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def public_dir(self) -> str:
|
|
54
|
+
path = self.__config.database_public
|
|
55
|
+
if path is None:
|
|
56
|
+
path = Path.join(self.root_dir, 'public')
|
|
57
|
+
return path
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def protected_dir(self) -> str:
|
|
61
|
+
path = self.__config.database_protected
|
|
62
|
+
if path is None:
|
|
63
|
+
path = Path.join(self.root_dir, 'protected')
|
|
64
|
+
return path
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def private_dir(self) -> str:
|
|
68
|
+
path = self.__config.database_private
|
|
69
|
+
if path is None:
|
|
70
|
+
path = Path.join(self.root_dir, 'private')
|
|
71
|
+
return path
|
|
60
72
|
|
|
61
73
|
def public_path(self, template: str):
|
|
62
74
|
""" replace '{PUBLIC}' with public directory """
|
|
63
75
|
tag = '{PUBLIC}'
|
|
64
76
|
if template.startswith(tag):
|
|
65
77
|
# replace with tag
|
|
66
|
-
return template_replace(template=template, key='PUBLIC', value=self.
|
|
78
|
+
return template_replace(template=template, key='PUBLIC', value=self.public_dir)
|
|
79
|
+
elif template.startswith('/') or template.find(':') > 0:
|
|
80
|
+
# absolute path
|
|
81
|
+
return template
|
|
82
|
+
else:
|
|
83
|
+
# relative path
|
|
84
|
+
return Path.join(self.public_dir, template)
|
|
85
|
+
|
|
86
|
+
def protected_path(self, template: str):
|
|
87
|
+
""" replace '{PROTECTED}' with protected directory """
|
|
88
|
+
tag = '{PROTECTED}'
|
|
89
|
+
if template.startswith(tag):
|
|
90
|
+
# replace with tag
|
|
91
|
+
return template_replace(template=template, key='PROTECTED', value=self.protected_dir)
|
|
67
92
|
elif template.startswith('/') or template.find(':') > 0:
|
|
68
93
|
# absolute path
|
|
69
94
|
return template
|
|
70
95
|
else:
|
|
71
96
|
# relative path
|
|
72
|
-
return Path.join(self.
|
|
97
|
+
return Path.join(self.protected_dir, template)
|
|
73
98
|
|
|
74
99
|
def private_path(self, template: str):
|
|
75
100
|
""" replace '{PRIVATE}' with private directory """
|
|
76
101
|
tag = '{PRIVATE}'
|
|
77
102
|
if template.startswith(tag):
|
|
78
103
|
# replace with tag
|
|
79
|
-
return template_replace(template=template, key='PRIVATE', value=self.
|
|
104
|
+
return template_replace(template=template, key='PRIVATE', value=self.private_dir)
|
|
80
105
|
elif template.startswith('/') or template.find(':') > 0:
|
|
81
106
|
# absolute path
|
|
82
107
|
return template
|
|
83
108
|
else:
|
|
84
109
|
# relative path
|
|
85
|
-
return Path.join(self.
|
|
110
|
+
return Path.join(self.private_dir, template)
|
|
86
111
|
|
|
87
112
|
@classmethod
|
|
88
113
|
async def read_text(cls, path: str) -> Optional[str]:
|
|
@@ -62,7 +62,7 @@ class DocumentStorage(Storage):
|
|
|
62
62
|
async def load_documents(self, identifier: ID) -> Optional[List[Document]]:
|
|
63
63
|
""" load documents from file """
|
|
64
64
|
path = self.__docs_path(identifier=identifier)
|
|
65
|
-
self.info(msg='Loading documents from: %s' % path)
|
|
65
|
+
# self.info(msg='Loading documents from: %s' % path)
|
|
66
66
|
array = await self.read_json(path=path)
|
|
67
67
|
if array is None:
|
|
68
68
|
# file not found
|