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
84e5289d
Commit
84e5289d
authored
4 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Add system.notify() method for notifying user/operator of an important event.
parent
3072aaa2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/js_system.c
+59
-2
59 additions, 2 deletions
src/sbbs3/js_system.c
with
59 additions
and
2 deletions
src/sbbs3/js_system.c
+
59
−
2
View file @
84e5289d
...
...
@@ -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
},
...
...
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