Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
85b2d84f
Commit
85b2d84f
authored
21 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
The beginnings of control/contribution support.
parent
80676014
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/listserver.js
+109
-5
109 additions, 5 deletions
exec/listserver.js
with
109 additions
and
5 deletions
exec/listserver.js
+
109
−
5
View file @
85b2d84f
...
@@ -10,7 +10,7 @@ log(LOG_INFO,"Synchronet ListServer " + REVISION);
...
@@ -10,7 +10,7 @@ log(LOG_INFO,"Synchronet ListServer " + REVISION);
js
.
auto_terminate
=
false
;
js
.
auto_terminate
=
false
;
var
ini_fname
=
system
.
ctrl_dir
+
"
listserv.ini
"
;
var
ini_fname
=
system
.
ctrl_dir
+
"
listserv
er
.ini
"
;
ini_file
=
new
File
(
ini_fname
);
ini_file
=
new
File
(
ini_fname
);
if
(
!
ini_file
.
open
(
"
r
"
))
{
if
(
!
ini_file
.
open
(
"
r
"
))
{
...
@@ -18,6 +18,7 @@ if(!ini_file.open("r")) {
...
@@ -18,6 +18,7 @@ if(!ini_file.open("r")) {
,
ini_file
.
error
,
ini_fname
));
,
ini_file
.
error
,
ini_fname
));
exit
();
exit
();
}
}
name_list
=
ini_file
.
iniGetValue
(
"
config
"
,
"
names
"
,
new
Array
());
list_array
=
ini_file
.
iniGetAllObjects
(
"
name
"
,
"
list:
"
);
list_array
=
ini_file
.
iniGetAllObjects
(
"
name
"
,
"
list:
"
);
ini_file
.
close
();
ini_file
.
close
();
if
(
!
list_array
.
length
)
{
if
(
!
list_array
.
length
)
{
...
@@ -25,7 +26,75 @@ if(!list_array.length) {
...
@@ -25,7 +26,75 @@ if(!list_array.length) {
exit
();
exit
();
}
}
if
(
this
.
message_text_filename
!=
undefined
)
{
/* Subscription control */
if
(
this
.
recipient_list_filename
!=
undefined
)
{
/* Subscription control */
var
error_file
=
new
File
(
processing_error_filename
);
if
(
!
error_file
.
open
(
"
w
"
))
{
log
(
LOG_ERR
,
format
(
"
!ERROR %s opening processing error file: %s
"
,
error_file
.
error
,
processing_error_filename
));
exit
();
}
var
rcptlst_file
=
new
File
(
recipient_list_filename
);
if
(
!
rcptlst_file
.
open
(
"
r
"
))
{
error_file
.
writeln
(
log
(
LOG_ERR
,
format
(
"
!ERROR %s opening recipient list: %s
"
,
rcptlst_file
.
error
,
recipient_list_filename
)));
exit
();
}
var
rcpt_list
=
rcptlst_file
.
iniGetAllObjects
(
"
number
"
);
rcptlst_file
.
close
();
var
msgtxt_file
=
new
File
(
message_text_filename
);
if
(
!
msgtxt_file
.
open
(
"
r
"
))
{
error_file
.
writeln
(
log
(
LOG_ERR
,
format
(
"
!ERROR %s opening recipient list: %s
"
,
msgtxt_file
.
error
,
message_text_filename
)));
exit
();
}
msgtxt
=
msgtxt_file
.
readAll
()
msgtxt_file
.
close
();
load
(
"
mailproc_util.js
"
);
// import parse_msg_header() and get_msg_body()
var
header
=
parse_msg_header
(
msgtxt
);
var
body
=
get_msg_body
(
msgtxt
);
/* control message for list server? */
for
(
r
=
0
;
r
<
rcpt_list
.
length
;
r
++
)
{
for
(
n
=
0
;
n
<
name_list
.
length
;
n
++
)
{
if
(
rcpt_list
[
r
].
Recipient
.
search
(
new
RegExp
(
name_list
[
n
],
"
i
"
))
!=-
1
)
break
;
}
if
(
n
<
name_list
.
length
)
/* match found */
break
;
}
if
(
r
<
rcpt_list
.
length
)
{
log
(
LOG_INFO
,
format
(
"
ListServer Control message from %s to %s: %s
"
,
header
.
from
,
header
.
to
,
header
.
subject
));
process_control_msg
(
header
,
body
);
exit
();
}
/* contribution to mailing list? */
var
contribution
=
false
;
for
(
r
=
0
;
r
<
rcpt_list
.
length
;
r
++
)
{
for
(
l
=
0
;
l
<
list_array
.
length
;
l
++
)
{
if
(
rcpt_list
[
r
].
Recipient
.
match
(
/
(\S
+
)
@/
)[
1
].
toLowerCase
()
==
list_array
[
l
].
name
&&
!
list_array
[
l
].
disabled
&&
!
list_array
[
l
].
readonly
)
break
;
}
if
(
l
<
list_array
.
length
)
{
/* match found */
log
(
LOG_INFO
,
format
(
"
ListServer Contribution message from %s to %s: %s
"
,
header
.
from
,
rcpt_list
[
r
].
Recipient
,
header
.
subject
));
if
(
!
process_contribution
(
header
,
body
,
list_array
[
l
]))
break
;
}
}
exit
();
exit
();
}
}
...
@@ -57,7 +126,7 @@ for(l in list_array) {
...
@@ -57,7 +126,7 @@ for(l in list_array) {
}
}
/* Get user (subscriber) list */
/* Get user (subscriber) list */
user_fname
=
msgbase
.
file
+
"
.list
serv
.users
"
;
user_fname
=
msgbase
.
file
+
"
.list.users
"
;
user_file
=
new
File
(
user_fname
);
user_file
=
new
File
(
user_fname
);
if
(
!
user_file
.
open
(
"
r
"
))
{
if
(
!
user_file
.
open
(
"
r
"
))
{
log
(
LOG_ERR
,
format
(
"
%s !ERROR %s opening file: %s
"
log
(
LOG_ERR
,
format
(
"
%s !ERROR %s opening file: %s
"
...
@@ -76,7 +145,7 @@ for(l in list_array) {
...
@@ -76,7 +145,7 @@ for(l in list_array) {
***/
***/
/* Get export message pointer */
/* Get export message pointer */
ptr_fname
=
msgbase
.
file
+
"
.list
serv
.ptr
"
;
ptr_fname
=
msgbase
.
file
+
"
.list.ptr
"
;
ptr_file
=
new
File
(
ptr_fname
);
ptr_file
=
new
File
(
ptr_fname
);
if
(
!
ptr_file
.
open
(
"
w+
"
))
{
if
(
!
ptr_file
.
open
(
"
w+
"
))
{
log
(
LOG_ERR
,
format
(
"
%s !ERROR %s opening/creating file: %s
"
log
(
LOG_ERR
,
format
(
"
%s !ERROR %s opening/creating file: %s
"
...
@@ -173,3 +242,38 @@ for(l in list_array) {
...
@@ -173,3 +242,38 @@ for(l in list_array) {
/* clean-up */
/* clean-up */
mailbase
.
close
();
mailbase
.
close
();
/* End of Main */
/* Handle Mailing List Control Messages (e.g. subscribe/unsubscribe) here */
function
process_control_msg
(
header
,
body
)
{
}
/* Handle Mailing List Contributions here */
function
process_contribution
(
header
,
body
,
list
)
{
// ToDo: apply filtering here?
var
msgbase
=
new
MsgBase
(
list
.
sub
);
// ToDo: verify author/sender is a list subscriber here
if
(
!
msgbase
.
open
())
{
error_file
.
writeln
(
log
(
LOG_ERR
,
format
(
"
%s !ERROR %s opening msgbase: %s
"
,
list
.
name
,
msgbase
.
error
,
list
.
sub
)));
return
(
false
);
}
// ToDo: Split header.from into separate name/address fields here
header
.
id
=
header
[
"
message-id
"
];
// Convert to Synchronet-compatible
if
(
!
msgbase
.
save_msg
(
header
,
body
.
join
(
'
\r\n
'
)))
{
log
(
LOG_ERR
,
format
(
"
%s !ERROR %s saving message to sub: %s
"
,
list
.
name
,
msgbase
.
error
,
list
.
sub
));
return
(
false
);
}
return
(
true
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment