copious-mail 0.9.0 → 0.9.1
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.
- package/README.md +111 -51
- package/client/hosted.html +112 -26
- package/lib/mail_repo_bridge_ops.js +48 -29
- package/lib/websocket_con.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,84 +1,144 @@
|
|
|
1
1
|
# copious-mail
|
|
2
|
+
|
|
2
3
|
This an interface for mail for a user. This is for reading, sending, editing, etc. It should work with more than one back-end and may have unconventional features as bonuses. The interface should be responsive and optionally work within a human-frame.
|
|
3
4
|
|
|
5
|
+
## client/hosted.html
|
|
4
6
|
|
|
7
|
+
This is an application page for use as part of the of-this.world frame applications.
|
|
5
8
|
|
|
9
|
+
This page contains code that talks to a human frame page, made for humans.
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
https://github.com/stackblitz/alien-signals
|
|
11
|
+
Messages go through the function **tell_frame_page** with codes that direct the human page to a mail iframe message handler. The message handler mostly provides authorization for host requests to go through, or may execute hosts requests on behalf of the mail page.
|
|
9
12
|
|
|
13
|
+
The human page may store mail for a user within his indexedDB tables, and the user may save the tables off line. Otherwise, the backed up mail will be stored on a server to which the hosted.html page will be able to send messages.
|
|
10
14
|
|
|
15
|
+
The webserver installatino of a hosted.html page shall be found be under copious-mail/index.html on sites made by copious.world. Users of this package may choose other locations.
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
The cusom user directories under **people** within the `/var/www/html` do not have to have a copy of this page. This page is generic and manages data.
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
### Mikado.js
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
This web page is using Mikado.js for listing emails, etc. There are some responsive application windows that are likely to be in vanilla javascript and HTML.
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
A more general use of mikado.js is being flushed out in grid-of-things. There has been some dependence on svelte.js, but it may be fading from those packages.
|
|
24
|
+
|
|
25
|
+
## node module
|
|
26
|
+
|
|
27
|
+
There is some library functionality produced with the package.
|
|
28
|
+
|
|
29
|
+
It is supposed to make it easy to make a server for the mail organization having to do with envelopes, types of messages, etc. This was thrown together for testing, but it proves useful in stacks closer to production.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### bin directory
|
|
34
|
+
|
|
35
|
+
The bin directory has web application based in ***polka***, a replacement for ***express.js.*** This is provided for testing. This packages is used within copious-transtion-apps as a DB proxy via the library. This package does not install a command line command within the linux /usr/bin or other.
|
|
19
36
|
|
|
37
|
+
The server can be run by invoking the the *run* command in package.json. The following starts the server:
|
|
20
38
|
|
|
21
39
|
```
|
|
22
|
-
|
|
23
|
-
<tweets foreach="data.tweets">
|
|
24
|
-
<!-- new partial template -->
|
|
25
|
-
<tweet>
|
|
26
|
-
<h1>{{ data.title }}</h1>
|
|
27
|
-
<title>Comments:</title>
|
|
28
|
-
<div foreach="data.comments">
|
|
29
|
-
<!-- new partial template -->
|
|
30
|
-
<comment>
|
|
31
|
-
<p>{{ data.content }}</p>
|
|
32
|
-
<title>Replies:</title>
|
|
33
|
-
<div foreach="data.replies">
|
|
34
|
-
<!-- new partial template -->
|
|
35
|
-
<p>{{ data.content }}</p>
|
|
36
|
-
</div>
|
|
37
|
-
</comment>
|
|
38
|
-
</div>
|
|
39
|
-
</tweet>
|
|
40
|
-
</tweets>
|
|
40
|
+
npm run service
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
### lib directory
|
|
43
44
|
|
|
45
|
+
The top level file ***index.js*** exposes one class, **`MailRepoBridgeOps`**. This class echos many ops that take place on the hosted.js page. For instance, a mail may move from *drafts* to *sent* when a user successfully sends an email. The page tables will update, and a message will be sent to the server in order to carry out the same operation in the DB.
|
|
44
46
|
|
|
47
|
+
It is expected that the DB operation will succeed. However, if it does not, then when the page updates or receives data updates, the mail may reappear in its starting place. In other words, the view will reflect the state of the DB sooner or later.
|
|
45
48
|
|
|
49
|
+
The contstructor fo r the class has the following parameters: `constructor(conf,user_db,node_cit)`
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
https://www.youtube.com/watch?v=claxN4oxDuY
|
|
51
|
+
* **`conf`** - contains a field `contact_rooms` which is a list of "room" names, that exists to store contact messages (e.g. from a contact form on a web site). Later, more fields may be added if they are important.
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
https://arxiv.org/abs/2607.07663
|
|
53
|
+
* **`user_db`** - a json DB of users including mail and contacts
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
https://arxiv.org/abs/2505.22954
|
|
55
|
+
* **`mail_server_interface`** - an instance of node-citadel class, which provides JS interfaces to the citadel mail server (groupware server). This can be another class instance as well.
|
|
55
56
|
|
|
56
|
-
Novikov, Vu et al. (2025). "AlphaEvolve."
|
|
57
|
-
https://arxiv.org/abs/2506.13131
|
|
58
57
|
|
|
59
|
-
Wijk, Lin et al. (2024). "RE-Bench."
|
|
60
|
-
https://arxiv.org/abs/2411.15114
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
https://alignment.anthropic.com/2026/...
|
|
59
|
+
## Tracing through copious-transition-app with node-citadel
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
https://arxiv.org/abs/2607.27191
|
|
61
|
+
This has to do with the use of citadel mail server as a backend. This version is for running on single node with single core and relatively low memory.
|
|
67
62
|
|
|
68
|
-
Cunningham et al. (2026). "The Economics of Recursive Self-Improvement."
|
|
69
|
-
https://arxiv.org/abs/2609.15802
|
|
70
63
|
|
|
71
|
-
Burtsev (2026). "Recursive Criticality of AI Self-Improvement."
|
|
72
|
-
https://arxiv.org/abs/2609.00137
|
|
73
64
|
|
|
74
|
-
|
|
75
|
-
https://deepmind.google/research/publ...
|
|
65
|
+
Look for:
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
```
|
|
68
|
+
SEND MAIL TO SERVER
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This marks the spot where the mail goes out to the merged igid-captcha server.
|
|
72
|
+
|
|
73
|
+
The type: `mail_com_object` is a JSON RPC object.
|
|
74
|
+
|
|
75
|
+
* A call stack:
|
|
76
|
+
do_send_mail_closefader(event) -- closes the mail edit window and calls the following
|
|
77
|
+
|^
|
|
78
|
+
do_send_mail(event) -- sends one email g_current_email_list_for_op = [g_current_edit_email.id], which is used by the following
|
|
79
|
+
|^
|
|
80
|
+
send_email_list(from) -- from will be 'drafts' in this case
|
|
81
|
+
|^
|
|
82
|
+
send_emails(object_list) -- make a JSONRpc object with the send mail command in it.
|
|
83
|
+
|^
|
|
84
|
+
send_email_operation("send",mail_com_object,g_proxy.link_map.publish_entry)
|
|
85
|
+
|^
|
|
86
|
+
1. A request is made to the human page for a response containing a signing key, a transaction token
|
|
87
|
+
2. Calls PostData, for a secondary transition...
|
|
88
|
+
|
|
89
|
+
SERVER SIDE (captcha)
|
|
90
|
+
|
|
91
|
+
* safe_client_write(msg) -- communication to the citadel server
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
let msg = `ENT0 1|` + msgObject.as_parameters()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|^
|
|
98
|
+
* This is a citadel command handlers
|
|
99
|
+
|^
|
|
100
|
+
cit_interface.post_message(mobj) -- a method in node-citadel...
|
|
101
|
+
|^
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
async send_mails(mail_obj_list) {
|
|
105
|
+
let promises = []
|
|
106
|
+
for ( let mobj of mail_obj_list ) {
|
|
107
|
+
promises.push(this.cit_interface.post_message(mobj))
|
|
108
|
+
}
|
|
109
|
+
await Promise.allSettled(promises)
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|^
|
|
114
|
+
case "send-mail" -- changes the mail table locations, then calls the user's send_mail
|
|
115
|
+
|^
|
|
116
|
+
* repo_ops.handle_rpc(rpc_obect.method,rpc_obect.params) -- const {MailRepoBridgeOps} = require('copious-mail')
|
|
117
|
+
|
|
118
|
+
> see file ./lib/mail_repo_bridge_ops
|
|
119
|
+
> |^
|
|
120
|
+
* A method of the static DB called from the captcha merged IGID DB
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
async handle_general_jrpc(rpc_obect) {
|
|
124
|
+
if ( rpc_obect && this.repo_ops ) {
|
|
125
|
+
return await this.repo_ops.handle_rpc(rpc_obect.method,rpc_obect.params)
|
|
126
|
+
}
|
|
127
|
+
return false
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
|^
|
|
132
|
+
let state_object = await this.trans_engine.json_rpc_finalizer(post_body?.mail_command)
|
|
133
|
+
|^
|
|
134
|
+
finalize_transition(transition,post_body,elements,req) -- auth method for an email transition
|
|
79
135
|
|
|
80
|
-
|
|
81
|
-
|
|
136
|
+
## mikado usage
|
|
137
|
+
|
|
138
|
+
DOC IS HERE:
|
|
82
139
|
|
|
83
|
-
|
|
84
|
-
|
|
140
|
+
https://github.com/nextapps-de/mikado
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
npx mikado-compile ./tpl/
|
package/client/hosted.html
CHANGED
|
@@ -3354,6 +3354,53 @@ const FRAME_PAGE_RELATES_TO_PUBLISHER= "frame_page_publications"
|
|
|
3354
3354
|
const FRAME_ACTION_FROM_PUBLISHER = "publisher_app_requests_action"
|
|
3355
3355
|
|
|
3356
3356
|
|
|
3357
|
+
// CONSTANTS FOR SPECIAL APPS
|
|
3358
|
+
const FRAME_PAGE_TO_CHAT = "FRAME_PAGE_TO_CHAT"
|
|
3359
|
+
const FRAME_RELATES_TO_CHAT = "FRAME_RELATES_TO_CHAT"
|
|
3360
|
+
const CHAT_RELATES_TO_FRAME = "CHAT_TO_FRAME_RELATION"
|
|
3361
|
+
const HUMAN_PAGE_CHAT_TO_FRAME = "CHAT_TO_FRAME_MESSAGE"
|
|
3362
|
+
const FRAME_ACTION_FROM_CHAT = "CHAT_TO_FRAME_ACTION"
|
|
3363
|
+
|
|
3364
|
+
const FRAME_TO_CHAT = "FRAME_TO_CHAT"
|
|
3365
|
+
const HOSTED_CHAT_TO_FRAME = "HOSTED_CHAT_TO_FRAME"
|
|
3366
|
+
|
|
3367
|
+
const HUMAN_PAGE_CHAT_INITIALIZATION = "HUMAN_PAGE_CHAT_INITIALIZATION"
|
|
3368
|
+
//
|
|
3369
|
+
const INIT_CHAT_RESPONSE = "INIT_CHAT_RESPONSE"
|
|
3370
|
+
const FAILED_CHAT_RESPONSE = "FAILED_CHAT_RESPONSE"
|
|
3371
|
+
const INVITE_CHAT_RESPONSE = "INVITE_CHAT_RESPONSE"
|
|
3372
|
+
const UPDATE_MEMBER_STATE = "UPDATE_MEMBER_STATE"
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
const CHAT_JOIN_OK = "CHAT_JOIN_OK"
|
|
3376
|
+
const CHAT_LEAVING = "CHAT_LEAVING"
|
|
3377
|
+
const CHAT_PAUSING = "CHAT_PAUSING"
|
|
3378
|
+
const CHAT_MESSAGE = "CHAT_MESSAGE"
|
|
3379
|
+
const CHAT_UPDATE = "CHAT_UPDATE"
|
|
3380
|
+
const CHAT_TRANSACTION = "CHAT_TRANSACTION"
|
|
3381
|
+
const UNAUTHORIZED_CHAT_MESSAGE = "UNAUTHORIZED_CHAT_MESSAGE"
|
|
3382
|
+
|
|
3383
|
+
const FRAME_PAGE_TO_MAIL = "FRAME_PAGE_TO_MAIL"
|
|
3384
|
+
const MAIL_PAGE_TO_FRAME = "MAIL_PAGE_TO_FRAME"
|
|
3385
|
+
const FRAME_RELATES_TO_MAIL = "FRAME_RELATES_TO_MAIL"
|
|
3386
|
+
const MAIL_RELATES_TO_FRAME = "MAIL_RELATES_TO_FRAME"
|
|
3387
|
+
|
|
3388
|
+
const FRAME_PAGE_TO_WALLET = "FRAME_PAGE_TO_WALLET"
|
|
3389
|
+
const WALLET_PAGE_TO_FRAME = "WALLET_PAGE_TO_FRAME"
|
|
3390
|
+
const FRAME_RELATES_TO_WALLET = "FRAME_RELATES_TO_WALLET"
|
|
3391
|
+
const WALLET_RELATES_TO_FRAME = "WALLET_RELATES_TO_FRAME"
|
|
3392
|
+
|
|
3393
|
+
const FRAME_PAGE_TO_MARKET = "FRAME_PAGE_TO_MARKET"
|
|
3394
|
+
const MARKET_PAGE_TO_FRAME = "MARKET_PAGE_TO_FRAME"
|
|
3395
|
+
const FRAME_PAGE_RELATES_TO_MARKET = "FRAME_PAGE_RELATES_TO_MARKET"
|
|
3396
|
+
const MARKET_RELATES_TO_FRAME = "MARKET_RELATES_TO_FRAME"
|
|
3397
|
+
|
|
3398
|
+
const FRAME_PAGE_TO_SOCIAL = "FRAME_PAGE_TO_SOCIAL"
|
|
3399
|
+
const SOCIAL_PAGE_TO_FRAME = "SOCIAL_PAGE_TO_FRAME"
|
|
3400
|
+
const FRAME_PAGE_RELATES_TO_SOCIAL = "FRAME_PAGE_RELATES_TO_SOCIAL"
|
|
3401
|
+
const SOCIAL_RELATES_TO_FRAME = "SOCIAL_RELATES_TO_FRAME"
|
|
3402
|
+
|
|
3403
|
+
|
|
3357
3404
|
// APP PAGE
|
|
3358
3405
|
//
|
|
3359
3406
|
const HOSTED_APP_TO_FRAME = "hosted_app_to_frame"
|
|
@@ -3372,7 +3419,6 @@ const BUILDER_ACTION_TO_FRAME = "builder_page_request_action"
|
|
|
3372
3419
|
const WORKER_TO_FRAME = "worker_to_frame"
|
|
3373
3420
|
const WORKER_RELATES_TO_FRAME = "worker_request_action"
|
|
3374
3421
|
|
|
3375
|
-
|
|
3376
3422
|
//
|
|
3377
3423
|
// actions
|
|
3378
3424
|
const FRAME_COMPONENT_RESPOND = "respond"
|
|
@@ -3562,7 +3608,7 @@ function install_frame_page_response() {
|
|
|
3562
3608
|
let action = mobj.action
|
|
3563
3609
|
let direction = mobj.direction
|
|
3564
3610
|
//
|
|
3565
|
-
if ( direction ===
|
|
3611
|
+
if ( direction === FRAME_PAGE_TO_MAIL ) {
|
|
3566
3612
|
if ( category === FRAME_COMPONENT_SAY_ALIVE ) {
|
|
3567
3613
|
if ( action === FRAME_COMPONENT_RESPONDING ) {
|
|
3568
3614
|
console.log("functioning")
|
|
@@ -3608,11 +3654,16 @@ hosted_page_application_handlers = async (category,action,relationship,params) =
|
|
|
3608
3654
|
}
|
|
3609
3655
|
|
|
3610
3656
|
|
|
3657
|
+
// const FRAME_PAGE_TO_MAIL = "FRAME_PAGE_TO_MAIL"
|
|
3658
|
+
// const MAIL_PAGE_TO_FRAME = "MAIL_PAGE_TO_FRAME"
|
|
3659
|
+
// const FRAME_RELATES_TO_MAIL = "FRAME_RELATES_TO_MAIL"
|
|
3660
|
+
// const MAIL_RELATES_TO_FRAME = "MAIL_RELATES_TO_FRAME"
|
|
3661
|
+
|
|
3611
3662
|
function tell_frame_page(message) {
|
|
3612
3663
|
if ( !g_frame_page ) return(false)
|
|
3613
3664
|
let msg = Object.assign({},g_message_template)
|
|
3614
|
-
msg.direction =
|
|
3615
|
-
msg.relationship =
|
|
3665
|
+
msg.direction = MAIL_PAGE_TO_FRAME
|
|
3666
|
+
msg.relationship = MAIL_RELATES_TO_FRAME
|
|
3616
3667
|
msg.action = message.action
|
|
3617
3668
|
msg.category = message.category
|
|
3618
3669
|
msg.data = message.data
|
|
@@ -3718,16 +3769,19 @@ async function send_publication_command(command,object_data_meta,link_meta) {
|
|
|
3718
3769
|
return true
|
|
3719
3770
|
}
|
|
3720
3771
|
return false
|
|
3721
|
-
//
|
|
3722
3772
|
}
|
|
3723
3773
|
|
|
3724
3774
|
|
|
3775
|
+
/**
|
|
3776
|
+
* SEND MAIL TO SERVER
|
|
3777
|
+
*/
|
|
3725
3778
|
async function send_email_operation(command,mail_com_object,link_meta) {
|
|
3726
|
-
//
|
|
3779
|
+
//send_publication_command
|
|
3727
3780
|
let command_send_request = mail_com_object.authorizer
|
|
3728
3781
|
let primary_response = await send_publication_command(command,command_send_request,link_meta)
|
|
3729
3782
|
//
|
|
3730
3783
|
if ( primary_response.OK == "true" ) {
|
|
3784
|
+
let data_hash = "" // going to need to hash the mail com object
|
|
3731
3785
|
let upload_keys = primary_response.elements // should be produced by publication handling
|
|
3732
3786
|
let postable = Object.assign(com_obj,{
|
|
3733
3787
|
"token" : primary_response.token, // primary action token (key to secondary)
|
|
@@ -3745,6 +3799,7 @@ async function send_email_operation(command,mail_com_object,link_meta) {
|
|
|
3745
3799
|
}
|
|
3746
3800
|
}
|
|
3747
3801
|
//
|
|
3802
|
+
return false
|
|
3748
3803
|
}
|
|
3749
3804
|
|
|
3750
3805
|
async function app_run_file_op(file_obj,operation) {
|
|
@@ -3814,7 +3869,7 @@ async function app_get_file(name) {
|
|
|
3814
3869
|
async function app_check_session() {
|
|
3815
3870
|
if ( g_frame_page ) {
|
|
3816
3871
|
let message = {
|
|
3817
|
-
"category":
|
|
3872
|
+
"category": FRAME_ACTION_FROM_MAIL,
|
|
3818
3873
|
"action" : FRAME_CHECK_SESSION,
|
|
3819
3874
|
"data" : false
|
|
3820
3875
|
}
|
|
@@ -3867,7 +3922,7 @@ function some_def_bool(val) {
|
|
|
3867
3922
|
return !!(val)
|
|
3868
3923
|
}
|
|
3869
3924
|
|
|
3870
|
-
class
|
|
3925
|
+
class CTProxy {
|
|
3871
3926
|
|
|
3872
3927
|
|
|
3873
3928
|
constructor() {
|
|
@@ -4008,7 +4063,7 @@ class Proxy {
|
|
|
4008
4063
|
|
|
4009
4064
|
|
|
4010
4065
|
|
|
4011
|
-
let g_proxy = new
|
|
4066
|
+
let g_proxy = new CTProxy()
|
|
4012
4067
|
|
|
4013
4068
|
|
|
4014
4069
|
|
|
@@ -4872,7 +4927,7 @@ post_submit
|
|
|
4872
4927
|
let rpc_result = await send_email_operation("get",mail_com_object,g_proxy.link_map.get_entry)
|
|
4873
4928
|
// let port = web_page_port
|
|
4874
4929
|
// let url = `http://localhost:${port}/json/email`
|
|
4875
|
-
// let rpc_result = await
|
|
4930
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
4876
4931
|
|
|
4877
4932
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
4878
4933
|
console.log(rpc_result)
|
|
@@ -4886,13 +4941,13 @@ post_submit
|
|
|
4886
4941
|
|
|
4887
4942
|
|
|
4888
4943
|
async function load_a_bunch_of_contacts() {
|
|
4889
|
-
|
|
4890
|
-
|
|
4944
|
+
//
|
|
4945
|
+
let mail_com_object = new MailJsonRpc('contacts',"get-contacts")
|
|
4891
4946
|
let rpc_result = await send_email_operation("get",mail_com_object,g_proxy.link_map.get_entry)
|
|
4892
4947
|
|
|
4893
4948
|
// let port = web_page_port
|
|
4894
4949
|
// let url = `http://localhost:${port}/json/email`
|
|
4895
|
-
// let rpc_result = await
|
|
4950
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
4896
4951
|
|
|
4897
4952
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
4898
4953
|
console.log(rpc_result)
|
|
@@ -4925,13 +4980,12 @@ post_submit
|
|
|
4925
4980
|
*/
|
|
4926
4981
|
async function add_emails_to_server(to,object_list) {
|
|
4927
4982
|
// server communication
|
|
4928
|
-
let
|
|
4929
|
-
//
|
|
4983
|
+
let mail_com_object = new MailJsonRpc(to,"store-mail",object_list)
|
|
4930
4984
|
let rpc_result = await send_email_operation("store",mail_com_object,g_proxy.link_map.new_entry)
|
|
4931
4985
|
|
|
4932
4986
|
// let port = web_page_port
|
|
4933
4987
|
// let url = `http://localhost:${port}/json/email`
|
|
4934
|
-
// let rpc_result = await
|
|
4988
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
4935
4989
|
|
|
4936
4990
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
4937
4991
|
console.log(rpc_result)
|
|
@@ -4944,12 +4998,12 @@ post_submit
|
|
|
4944
4998
|
*/
|
|
4945
4999
|
async function delete_emails_from_server(from,id_list) {
|
|
4946
5000
|
// server communication
|
|
4947
|
-
let
|
|
5001
|
+
let mail_com_object = new MailJsonRpc(from,"remove-mail",id_list)
|
|
4948
5002
|
let rpc_result = await send_email_operation("delete",mail_com_object,g_proxy.link_map.delete_entry)
|
|
4949
5003
|
//
|
|
4950
5004
|
// let port = web_page_port
|
|
4951
5005
|
// let url = `http://localhost:${port}/json/email`
|
|
4952
|
-
// let rpc_result = await
|
|
5006
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
4953
5007
|
//
|
|
4954
5008
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
4955
5009
|
console.log(rpc_result)
|
|
@@ -4963,12 +5017,12 @@ post_submit
|
|
|
4963
5017
|
*/
|
|
4964
5018
|
async function send_emails(object_list) {
|
|
4965
5019
|
// server communication
|
|
4966
|
-
let
|
|
5020
|
+
let mail_com_object = new MailJsonRpc("sent","send-mail",object_list)
|
|
4967
5021
|
let rpc_result = await send_email_operation("send",mail_com_object,g_proxy.link_map.publish_entry)
|
|
4968
5022
|
|
|
4969
5023
|
// let port = web_page_port
|
|
4970
5024
|
// let url = `http://localhost:${port}/json/email`
|
|
4971
|
-
// let rpc_result = await
|
|
5025
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
4972
5026
|
|
|
4973
5027
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
4974
5028
|
return true
|
|
@@ -4981,12 +5035,12 @@ post_submit
|
|
|
4981
5035
|
*/
|
|
4982
5036
|
async function save_mail(email_obj) {
|
|
4983
5037
|
// server communicate
|
|
4984
|
-
let
|
|
5038
|
+
let mail_com_object = new MailJsonRpc("drafts","store-draft",email_obj)
|
|
4985
5039
|
let rpc_result = await send_email_operation("store",mail_com_object,g_proxy.link_map.new_entry)
|
|
4986
5040
|
|
|
4987
5041
|
// let port = web_page_port
|
|
4988
5042
|
// let url = `http://localhost:${port}/json/email`
|
|
4989
|
-
// let rpc_result = await
|
|
5043
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
4990
5044
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
4991
5045
|
return true
|
|
4992
5046
|
}
|
|
@@ -4999,12 +5053,12 @@ post_submit
|
|
|
4999
5053
|
*/
|
|
5000
5054
|
async function remove_contact_from_server(a_contact) {
|
|
5001
5055
|
// server communication
|
|
5002
|
-
let
|
|
5056
|
+
let mail_com_object = new MailJsonRpc("contacts","remove-contact",a_contact)
|
|
5003
5057
|
let rpc_result = await send_email_operation("get",mail_com_object,g_proxy.link_map.delete_entry)
|
|
5004
5058
|
|
|
5005
5059
|
// let port = web_page_port
|
|
5006
5060
|
// let url = `http://localhost:${port}/json/email`
|
|
5007
|
-
// let rpc_result = await
|
|
5061
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
5008
5062
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
5009
5063
|
return true
|
|
5010
5064
|
}
|
|
@@ -5015,12 +5069,12 @@ post_submit
|
|
|
5015
5069
|
*/
|
|
5016
5070
|
async function save_contact(edited_contact) {
|
|
5017
5071
|
// server communication
|
|
5018
|
-
let
|
|
5072
|
+
let mail_com_object = new MailJsonRpc("contacts","store-contact",edited_contact)
|
|
5019
5073
|
let rpc_result = await send_email_operation("store",mail_com_object,g_proxy.link_map.new_entry)
|
|
5020
5074
|
|
|
5021
5075
|
// let port = web_page_port
|
|
5022
5076
|
// let url = `http://localhost:${port}/json/email`
|
|
5023
|
-
// let rpc_result = await
|
|
5077
|
+
// let rpc_result = await ctxt_postData(url, data)
|
|
5024
5078
|
//
|
|
5025
5079
|
if ( rpc_result && (rpc_result.error === undefined) ) {
|
|
5026
5080
|
return true
|
|
@@ -5030,6 +5084,38 @@ post_submit
|
|
|
5030
5084
|
|
|
5031
5085
|
|
|
5032
5086
|
|
|
5087
|
+
</script>
|
|
5088
|
+
<script>
|
|
5089
|
+
|
|
5090
|
+
// vanilla version
|
|
5091
|
+
async function ctxt_postData(url = '', data = {}, creds = 'omit', do_stringify = true, ctype) {
|
|
5092
|
+
return await postData(url, data, creds, do_stringify, ctype)
|
|
5093
|
+
}
|
|
5094
|
+
|
|
5095
|
+
async function ctxt_post_submit(fields) {
|
|
5096
|
+
return await post_submit(fields)
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
async function ctxt_make_host_request(endpoint,data) {
|
|
5100
|
+
return await make_host_request(endpoint,data)
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
async function ctxt_postDataWithRefer(url = '', data = {}, creds = 'omit', do_stringify = true, ctype) {
|
|
5104
|
+
return postDataWithRefer(url, data, creds, do_stringify, ctype)
|
|
5105
|
+
}
|
|
5106
|
+
|
|
5107
|
+
async function ctxt_fetchTextFile(endpoint,port) {
|
|
5108
|
+
return await fetchTextFile(endpoint,port)
|
|
5109
|
+
}
|
|
5110
|
+
|
|
5111
|
+
async function ctxt_fetchEndPoint(endpoint,port) {
|
|
5112
|
+
return fetchEndPoint(endpoint,port)
|
|
5113
|
+
}
|
|
5114
|
+
|
|
5115
|
+
async function ctxt_fetchUrl(endpoint) {
|
|
5116
|
+
return fetchUrl(endpoint)
|
|
5117
|
+
}
|
|
5118
|
+
|
|
5033
5119
|
</script>
|
|
5034
5120
|
<script>
|
|
5035
5121
|
//
|
|
@@ -96,7 +96,7 @@ class Attachment {
|
|
|
96
96
|
class LocalCacheStorage {
|
|
97
97
|
|
|
98
98
|
constructor(prev_cache) {
|
|
99
|
-
this.
|
|
99
|
+
this.mail_interface = false
|
|
100
100
|
this.all_storage_classes = {
|
|
101
101
|
'inbox' : {},
|
|
102
102
|
'sent' : {},
|
|
@@ -120,7 +120,7 @@ class LocalCacheStorage {
|
|
|
120
120
|
'contacts' : {}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
this.
|
|
123
|
+
this.server_token_name = {
|
|
124
124
|
'inbox' : "_MAIL_", // should consider that all mail may contain spam and notification (as a mail type)
|
|
125
125
|
'sent' : "Sent Items",
|
|
126
126
|
'drafts' : "_DRAFTS_",
|
|
@@ -145,13 +145,13 @@ class LocalCacheStorage {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
return this.
|
|
148
|
+
server_token_name(mtype) {
|
|
149
|
+
return this.server_token_name[mtype]
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
this.
|
|
153
|
+
set_mail_interface(mail_server_interface) {
|
|
154
|
+
this.mail_interface = mail_server_interface
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
|
|
@@ -250,8 +250,8 @@ class LocalCacheStorage {
|
|
|
250
250
|
if ( contact_set ) {
|
|
251
251
|
for ( let c of contact_list ) {
|
|
252
252
|
contact_set[c.id] = structuredClone(c)
|
|
253
|
-
if ( this.
|
|
254
|
-
await this.
|
|
253
|
+
if ( this.mail_interface ) {
|
|
254
|
+
await this.mail_interface.add_contact(contact_set[c.id]) // EXAMPLE
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
}
|
|
@@ -276,7 +276,7 @@ class LocalCacheStorage {
|
|
|
276
276
|
* @returns {Array}
|
|
277
277
|
*/
|
|
278
278
|
get_contacts() {
|
|
279
|
-
if ( this.
|
|
279
|
+
if ( this.mail_interface ) {
|
|
280
280
|
this.cit_synch_load('contacts')
|
|
281
281
|
}
|
|
282
282
|
let contact_set = this.all_storage_classes['contacts']
|
|
@@ -288,7 +288,7 @@ class LocalCacheStorage {
|
|
|
288
288
|
* @returns {Array}
|
|
289
289
|
*/
|
|
290
290
|
get_contacts_ids() {
|
|
291
|
-
if ( this.
|
|
291
|
+
if ( this.mail_interface ) {
|
|
292
292
|
this.cit_synch_load('contacts')
|
|
293
293
|
}
|
|
294
294
|
let contact_set = this.all_storage_classes['contacts']
|
|
@@ -307,7 +307,7 @@ class LocalCacheStorage {
|
|
|
307
307
|
async send_mails(mail_obj_list) {
|
|
308
308
|
let promises = []
|
|
309
309
|
for ( let mobj of mail_obj_list ) {
|
|
310
|
-
promises.push(this.
|
|
310
|
+
promises.push(this.mail_interface.post_message(mobj))
|
|
311
311
|
}
|
|
312
312
|
await Promise.allSettled(promises)
|
|
313
313
|
}
|
|
@@ -345,8 +345,8 @@ class LocalCacheStorage {
|
|
|
345
345
|
delete mail_obj.bcc
|
|
346
346
|
}
|
|
347
347
|
//
|
|
348
|
-
await this.
|
|
349
|
-
await this.
|
|
348
|
+
await this.mail_interface.goto_room('drafts')
|
|
349
|
+
await this.mail_interface.post_message(mail_obj)
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
/**
|
|
@@ -403,28 +403,47 @@ class LocalCacheStorage {
|
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
/**
|
|
407
|
+
*
|
|
408
|
+
* @param {string} mtype
|
|
409
|
+
*/
|
|
406
410
|
async cit_synch_load(mtype) {
|
|
407
|
-
await this.
|
|
408
|
-
let mail_list = await this.
|
|
411
|
+
await this.mail_interface.goto_room(this.server_token_name(mtype))
|
|
412
|
+
let mail_list = await this.mail_interface.get_messages("ALL")
|
|
409
413
|
this.store_mails(mtype,mail_list)
|
|
410
414
|
}
|
|
411
415
|
|
|
412
416
|
|
|
413
|
-
|
|
417
|
+
/**
|
|
418
|
+
*
|
|
419
|
+
* @param {string} mtype
|
|
420
|
+
* @param {string} id
|
|
421
|
+
*/
|
|
414
422
|
async del_from_storage(mtype,id) {
|
|
415
|
-
await this.user_data[user]?.
|
|
416
|
-
await this.user_data[user]?.
|
|
423
|
+
await this.user_data[user]?.mail_interface?.goto_room(this.server_token_name(mtype))
|
|
424
|
+
await this.user_data[user]?.mail_interface?.delete_message(id)
|
|
417
425
|
}
|
|
418
426
|
|
|
427
|
+
/**
|
|
428
|
+
*
|
|
429
|
+
* @param {string} mtype
|
|
430
|
+
* @param {object} mail_obj
|
|
431
|
+
* @param {boolean} dogo
|
|
432
|
+
*/
|
|
419
433
|
async add_to_storage(mtype,mail_obj,dogo = false) {
|
|
420
434
|
if ( dogo ) {
|
|
421
|
-
await this.
|
|
435
|
+
await this.mail_interface.goto_room(this.server_token_name(mtype))
|
|
422
436
|
}
|
|
423
|
-
await this.
|
|
437
|
+
await this.mail_interface.post_message(mail_obj)
|
|
424
438
|
}
|
|
425
439
|
|
|
440
|
+
/**
|
|
441
|
+
*
|
|
442
|
+
* @param {string} mtype
|
|
443
|
+
* @param {Array} mail_list
|
|
444
|
+
*/
|
|
426
445
|
async add_list_to_storage(mtype,mail_list) {
|
|
427
|
-
await this.
|
|
446
|
+
await this.mail_interface.goto_room(this.server_token_name(mtype))
|
|
428
447
|
for ( let mobj of mail_list ) {
|
|
429
448
|
await this.add_to_storage(mtype,mobj)
|
|
430
449
|
}
|
|
@@ -437,16 +456,16 @@ class LocalCacheStorage {
|
|
|
437
456
|
*/
|
|
438
457
|
class MailRepoBridgeOps {
|
|
439
458
|
|
|
440
|
-
constructor(conf,user_db,
|
|
459
|
+
constructor(conf,user_db,mail_server_interface) {
|
|
441
460
|
//
|
|
442
|
-
this.node_cit =
|
|
461
|
+
this.node_cit = mail_server_interface
|
|
443
462
|
//
|
|
444
463
|
this.sim_date = new Date()
|
|
445
464
|
//
|
|
446
465
|
this.largest_id = 100
|
|
447
466
|
this.user_data = structuredClone(user_db)
|
|
448
467
|
|
|
449
|
-
this.initialize_user_caches(
|
|
468
|
+
this.initialize_user_caches(mail_server_interface)
|
|
450
469
|
//
|
|
451
470
|
this.messages_sent = true
|
|
452
471
|
|
|
@@ -490,13 +509,13 @@ class MailRepoBridgeOps {
|
|
|
490
509
|
*
|
|
491
510
|
* @param {object} node_cit -- node-citadel class instance
|
|
492
511
|
*/
|
|
493
|
-
initialize_user_caches(
|
|
512
|
+
initialize_user_caches(mail_server_interface) {
|
|
494
513
|
if ( typeof this.user_data === "object" ) {
|
|
495
514
|
for ( let user in this.user_data ) {
|
|
496
515
|
let prev_messages = user.mail_cache
|
|
497
516
|
let user_cache = new LocalCacheStorage(prev_messages)
|
|
498
517
|
this.user_data[user].cache = user_cache
|
|
499
|
-
user_cache.
|
|
518
|
+
user_cache.set_mail_interface(mail_server_interface)
|
|
500
519
|
}
|
|
501
520
|
}
|
|
502
521
|
}
|
|
@@ -820,7 +839,7 @@ class MailRepoBridgeOps {
|
|
|
820
839
|
this.user_data[user].cache.drop_recipients_of_msgs(mail_id_list)
|
|
821
840
|
this.user_data[user].cache.move_mails(mtype,dst_type,mail_id_list)
|
|
822
841
|
// not clear if this next line needs to be called...
|
|
823
|
-
await this.user_data[user]?.
|
|
842
|
+
await this.user_data[user]?.mail_interface?.move_message_list(mail_id_list,dst_type)
|
|
824
843
|
results = {
|
|
825
844
|
"result" : true
|
|
826
845
|
}
|
|
@@ -839,7 +858,7 @@ class MailRepoBridgeOps {
|
|
|
839
858
|
this.user_data[user].cache.drop_recipients_of_msgs(mail_id_list)
|
|
840
859
|
}
|
|
841
860
|
this.user_data[user].cache.move_mails(mtype,dst_type,mail_id_list)
|
|
842
|
-
await this.user_data[user]?.
|
|
861
|
+
await this.user_data[user]?.mail_interface?.move_message_list(mail_id_list,dst_type)
|
|
843
862
|
results = {
|
|
844
863
|
"result" : true
|
|
845
864
|
}
|
|
@@ -853,7 +872,7 @@ class MailRepoBridgeOps {
|
|
|
853
872
|
let mtype = params.mail_type
|
|
854
873
|
let user = params.user
|
|
855
874
|
this.user_data[user].cache.store_mails(mtype,[mail_object])
|
|
856
|
-
await this.user_data[user]?.
|
|
875
|
+
await this.user_data[user]?.mail_interface?.store_draft(mail_object)
|
|
857
876
|
results = {
|
|
858
877
|
"result" : true
|
|
859
878
|
}
|
package/lib/websocket_con.js
CHANGED