Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Synchronet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
139
Issues
139
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main
Synchronet
Commits
c98ed907
Commit
c98ed907
authored
Sep 13, 2020
by
Rob Swindell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system.notify() method for notifying user/operator of an important event.
parent
a67c762b
Pipeline
#131
passed with stage
in 11 minutes
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
2 deletions
+59
-2
src/sbbs3/js_system.c
src/sbbs3/js_system.c
+59
-2
No files found.
src/sbbs3/js_system.c
View file @
c98ed907
...
...
@@ -1589,6 +1589,59 @@ js_put_telegram(JSContext *cx, uintN argc, jsval *arglist)
return
(
JS_TRUE
);
}
static
JSBool
js_notify
(
JSContext
*
cx
,
uintN
argc
,
jsval
*
arglist
)
{
JSObject
*
obj
=
JS_THIS_OBJECT
(
cx
,
arglist
);
jsval
*
argv
=
JS_ARGV
(
cx
,
arglist
);
int32
usernumber
=
1
;
JSString
*
js_subj
;
JSString
*
js_msg
;
char
*
subj
;
char
*
msg
=
NULL
;
jsrefcount
rc
;
BOOL
ret
;
JS_SET_RVAL
(
cx
,
arglist
,
JSVAL_VOID
);
js_system_private_t
*
sys
;
if
((
sys
=
(
js_system_private_t
*
)
js_GetClassPrivate
(
cx
,
obj
,
&
js_system_class
))
==
NULL
)
return
JS_FALSE
;
JS_ValueToInt32
(
cx
,
argv
[
0
],
&
usernumber
);
if
(
usernumber
<
1
)
usernumber
=
1
;
if
((
js_subj
=
JS_ValueToString
(
cx
,
argv
[
1
]))
==
NULL
)
return
JS_FALSE
;
if
(
argc
>
2
)
{
if
((
js_msg
=
JS_ValueToString
(
cx
,
argv
[
2
]))
==
NULL
)
return
JS_FALSE
;
JSSTRING_TO_MSTRING
(
cx
,
js_msg
,
msg
,
NULL
);
HANDLE_PENDING
(
cx
,
msg
);
if
(
msg
==
NULL
)
return
JS_TRUE
;
}
JSSTRING_TO_MSTRING
(
cx
,
js_subj
,
subj
,
NULL
);
HANDLE_PENDING
(
cx
,
subj
);
if
(
subj
==
NULL
)
{
free
(
msg
);
return
JS_TRUE
;
}
rc
=
JS_SUSPENDREQUEST
(
cx
);
ret
=
notify
(
sys
->
cfg
,
usernumber
,
subj
,
msg
)
==
0
;
free
(
subj
);
free
(
msg
);
JS_RESUMEREQUEST
(
cx
,
rc
);
JS_SET_RVAL
(
cx
,
arglist
,
BOOLEAN_TO_JSVAL
(
ret
));
return
JS_TRUE
;
}
static
JSBool
js_new_user
(
JSContext
*
cx
,
uintN
argc
,
jsval
*
arglist
)
{
...
...
@@ -1905,7 +1958,7 @@ js_killpid(JSContext *cx, uintN argc, jsval *arglist)
static
jsSyncMethodSpec
js_system_functions
[]
=
{
#ifndef JSDOOR
{
"username"
,
js_username
,
1
,
JSTYPE_STRING
,
JSDOCSTR
(
"number"
)
{
"username"
,
js_username
,
1
,
JSTYPE_STRING
,
JSDOCSTR
(
"
user_
number"
)
,
JSDOCSTR
(
"returns name of user in specified user record <i>number</i>, or empty string if not found"
)
,
311
},
...
...
@@ -1986,6 +2039,10 @@ static jsSyncMethodSpec js_system_functions[] = {
,
JSDOCSTR
(
"sends a user a short text message, delivered immediately or during next logon"
)
,
310
},
{
"notify"
,
js_notify
,
2
,
JSTYPE_BOOLEAN
,
JSDOCSTR
(
"user_number, subject [,message_text]"
)
,
JSDOCSTR
(
"notify a user or operator via both email and a short text message about an important event"
)
,
31801
},
{
"newuser"
,
js_new_user
,
1
,
JSTYPE_ALIAS
},
{
"new_user"
,
js_new_user
,
1
,
JSTYPE_OBJECT
,
JSDOCSTR
(
"name/alias [,client object]"
)
,
JSDOCSTR
(
"creates a new user record, returns a new <a href=#User>User</a> object representing the new user account, on success.<br>"
...
...
@@ -1993,7 +2050,7 @@ static jsSyncMethodSpec js_system_functions[] = {
"client object is used if the argument is omitted)"
)
,
310
},
{
"del_user"
,
js_del_user
,
1
,
JSTYPE_BOOLEAN
,
JSDOCSTR
(
"number"
)
{
"del_user"
,
js_del_user
,
1
,
JSTYPE_BOOLEAN
,
JSDOCSTR
(
"
user_
number"
)
,
JSDOCSTR
(
"delete the specified user account"
)
,
316
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment