Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
signalboost
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
gagz
signalboost
Commits
b9886fe6
Verified
Commit
b9886fe6
authored
5 years ago
by
aguestuser
Browse files
Options
Downloads
Patches
Plain Diff
[131][WIP] deconfuse messages
TODO: translations, testing!
parent
f00daa36
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/dispatcher/messenger.js
+15
-18
15 additions, 18 deletions
app/services/dispatcher/messenger.js
app/services/dispatcher/strings/messages/EN.js
+12
-4
12 additions, 4 deletions
app/services/dispatcher/strings/messages/EN.js
with
27 additions
and
22 deletions
app/services/dispatcher/messenger.js
+
15
−
18
View file @
b9886fe6
...
@@ -18,13 +18,13 @@ const {
...
@@ -18,13 +18,13 @@ const {
const
messageTypes
=
{
const
messageTypes
=
{
BROADCAST_MESSAGE
:
'
BROADCAST_MESSAGE
'
,
BROADCAST_MESSAGE
:
'
BROADCAST_MESSAGE
'
,
BROADCAST_RESPONSE
:
'
BROADCAST_RESPONS
E
'
,
HOTLINE_MESSAGE
:
'
HOTLINE_MESSAG
E
'
,
COMMAND_RESULT
:
'
COMMAND_RESULT
'
,
COMMAND_RESULT
:
'
COMMAND_RESULT
'
,
NEW_ADMIN_WELCOME
:
'
NEW_ADMIN_WELCOME
'
,
NEW_ADMIN_WELCOME
:
'
NEW_ADMIN_WELCOME
'
,
SIGNUP_MESSAGE
:
'
SIGNUP_MESSAGE
'
,
SIGNUP_MESSAGE
:
'
SIGNUP_MESSAGE
'
,
}
}
const
{
BROADCAST_MESSAGE
,
BROADCAST_RESPONS
E
,
COMMAND_RESULT
,
SIGNUP_MESSAGE
}
=
messageTypes
const
{
BROADCAST_MESSAGE
,
HOTLINE_MESSAG
E
,
COMMAND_RESULT
,
SIGNUP_MESSAGE
}
=
messageTypes
const
{
ADMIN
}
=
memberTypes
const
{
ADMIN
}
=
memberTypes
...
@@ -38,8 +38,8 @@ const dispatch = async ({ commandResult, dispatchable }) => {
...
@@ -38,8 +38,8 @@ const dispatch = async ({ commandResult, dispatchable }) => {
switch
(
messageType
)
{
switch
(
messageType
)
{
case
BROADCAST_MESSAGE
:
case
BROADCAST_MESSAGE
:
return
broadcast
(
dispatchable
)
return
broadcast
(
dispatchable
)
case
BROADCAST_RESPONS
E
:
case
HOTLINE_MESSAG
E
:
return
handle
BroadcastRespons
e
(
dispatchable
)
return
handle
HotlineMessag
e
(
dispatchable
)
case
COMMAND_RESULT
:
case
COMMAND_RESULT
:
return
handleCommandResult
({
commandResult
,
dispatchable
})
return
handleCommandResult
({
commandResult
,
dispatchable
})
case
SIGNUP_MESSAGE
:
case
SIGNUP_MESSAGE
:
...
@@ -54,7 +54,7 @@ const parseMessageType = (commandResult, { sender, channel }) => {
...
@@ -54,7 +54,7 @@ const parseMessageType = (commandResult, { sender, channel }) => {
if
(
commandResult
.
status
===
statuses
.
NOOP
)
{
if
(
commandResult
.
status
===
statuses
.
NOOP
)
{
if
(
sender
.
type
===
ADMIN
)
return
BROADCAST_MESSAGE
if
(
sender
.
type
===
ADMIN
)
return
BROADCAST_MESSAGE
if
(
channel
.
phoneNumber
===
signupPhoneNumber
)
return
SIGNUP_MESSAGE
if
(
channel
.
phoneNumber
===
signupPhoneNumber
)
return
SIGNUP_MESSAGE
return
BROADCAST_RESPONS
E
return
HOTLINE_MESSAG
E
}
}
return
COMMAND_RESULT
return
COMMAND_RESULT
}
}
...
@@ -78,20 +78,17 @@ const handleSignupMessage = async ({ sock, channel, sender, sdMessage }) => {
...
@@ -78,20 +78,17 @@ const handleSignupMessage = async ({ sock, channel, sender, sdMessage }) => {
})
})
}
}
const
handle
BroadcastRespons
e
=
dispatchable
=>
{
const
handle
HotlineMessag
e
=
dispatchable
=>
{
const
{
const
{
channel
:
{
responsesEnabled
},
channel
:
{
responsesEnabled
},
sender
:
{
language
},
sender
:
{
language
,
type
},
}
=
dispatchable
}
=
dispatchable
const
disabledMessage
=
messagesIn
(
language
).
notifications
.
hotlineMessagesDisabled
(
if
(
!
responsesEnabled
)
{
type
===
memberTypes
.
SUBSCRIBER
,
return
respond
({
)
...
dispatchable
,
return
responsesEnabled
message
:
messagesIn
(
language
).
notifications
.
unauthorized
,
?
relayBroadcastResponse
(
dispatchable
)
status
:
statuses
.
UNAUTHORIZED
,
:
respond
({
...
dispatchable
,
status
:
statuses
.
UNAUTHORIZED
,
message
:
disabledMessage
})
})
}
return
relayBroadcastResponse
(
dispatchable
)
}
}
const
handleCommandResult
=
async
({
commandResult
,
dispatchable
})
=>
{
const
handleCommandResult
=
async
({
commandResult
,
dispatchable
})
=>
{
...
@@ -145,7 +142,7 @@ const relayBroadcastResponse = async ({ db, sock, channel, sender, sdMessage })
...
@@ -145,7 +142,7 @@ const relayBroadcastResponse = async ({ db, sock, channel, sender, sdMessage })
const
{
language
}
=
sender
const
{
language
}
=
sender
const
recipients
=
channelRepository
.
getAdminPhoneNumbers
(
channel
)
const
recipients
=
channelRepository
.
getAdminPhoneNumbers
(
channel
)
const
notification
=
messagesIn
(
language
).
notifications
.
broadcastResponseSent
(
channel
)
const
notification
=
messagesIn
(
language
).
notifications
.
broadcastResponseSent
(
channel
)
const
outMessage
=
format
({
channel
,
sdMessage
,
messageType
:
BROADCAST_RESPONS
E
,
language
})
const
outMessage
=
format
({
channel
,
sdMessage
,
messageType
:
HOTLINE_MESSAG
E
,
language
})
return
signal
return
signal
.
broadcastMessage
(
sock
,
recipients
,
outMessage
)
.
broadcastMessage
(
sock
,
recipients
,
outMessage
)
.
then
(()
=>
countBroacast
({
db
,
channel
}))
.
then
(()
=>
countBroacast
({
db
,
channel
}))
...
@@ -184,7 +181,7 @@ const resolvePrefix = (channel, messageType, command, language) => {
...
@@ -184,7 +181,7 @@ const resolvePrefix = (channel, messageType, command, language) => {
// INFO & HELP messages provide their own prefixes
// INFO & HELP messages provide their own prefixes
return
''
return
''
}
}
if
(
messageType
===
BROADCAST_RESPONS
E
)
{
if
(
messageType
===
HOTLINE_MESSAG
E
)
{
// subscriber responses get a special header so they don't look like broadcast messages from admins
// subscriber responses get a special header so they don't look like broadcast messages from admins
// we clone message to preserve attachments
// we clone message to preserve attachments
return
`[
${
prefixes
.
broadcastResponse
}
]\n`
return
`[
${
prefixes
.
broadcastResponse
}
]\n`
...
...
This diff is collapsed.
Click to expand it.
app/services/dispatcher/strings/messages/EN.js
+
12
−
4
View file @
b9886fe6
...
@@ -5,9 +5,10 @@ const {
...
@@ -5,9 +5,10 @@ const {
}
=
require
(
'
../../../../db/repositories/channel
'
)
}
=
require
(
'
../../../../db/repositories/channel
'
)
const
systemName
=
'
the signalboost system administrator
'
const
systemName
=
'
the signalboost system administrator
'
const
unauthorized
=
'
Whoops! You are not authorized to do that on this channel.
'
const
unauthorized
=
'
Your message could not be processed because you are not subscribed to this channel. Send HELLO to subscribe.
'
const
invalidNumber
=
phoneNumber
=>
const
invalidNumber
=
phoneNumber
=>
`
Whoops!
"
${
phoneNumber
}
" is not a valid phone number. Phone numbers must include country codes prefixed by a '+'.`
`"
${
phoneNumber
}
" is not a valid phone number. Phone numbers must include country codes prefixed by a '+'.`
const
support
=
`----------------------------
const
support
=
`----------------------------
HOW IT WORKS
HOW IT WORKS
...
@@ -36,9 +37,11 @@ const notifications = {
...
@@ -36,9 +37,11 @@ const notifications = {
adminAdded
:
(
commandIssuer
,
addedAdmin
)
=>
`New Admin
${
addedAdmin
}
added by
${
commandIssuer
}
`
,
adminAdded
:
(
commandIssuer
,
addedAdmin
)
=>
`New Admin
${
addedAdmin
}
added by
${
commandIssuer
}
`
,
broadcastResponseSent
:
channel
=>
broadcastResponseSent
:
channel
=>
`Your message was forwarded to the admins of [
${
channel
.
name
}
].
`Your message was anonymously forwarded to the admins of [
${
channel
.
name
}
]. Please include your phone number if you want admins to respond to you.
Send HELP to see commands I understand! :)
`
,
You can also send HELP to list valid commands.
`
,
deauthorization
:
adminPhoneNumber
=>
`
deauthorization
:
adminPhoneNumber
=>
`
${
adminPhoneNumber
}
has been removed from this channel because their safety number changed.
${
adminPhoneNumber
}
has been removed from this channel because their safety number changed.
...
@@ -55,6 +58,11 @@ Until then, they will be unable to send messages to or read messages from this c
...
@@ -55,6 +58,11 @@ Until then, they will be unable to send messages to or read messages from this c
noop
:
"
Whoops! That's not a command!
"
,
noop
:
"
Whoops! That's not a command!
"
,
unauthorized
:
"
Whoops! I don't understand that.
\n
Send HELP to see commands I understand!
"
,
unauthorized
:
"
Whoops! I don't understand that.
\n
Send HELP to see commands I understand!
"
,
hotlineMessagesDisabled
:
isSubscriber
=>
isSubscriber
?
'
Sorry, incoming messages are not enabled on this channel. Send HELP to list valid commands.
'
:
'
Sorry, incoming messages are not enabled on this channel. Send HELLO to subscribe.
'
,
welcome
:
(
addingAdmin
,
channelPhoneNumber
)
=>
`
welcome
:
(
addingAdmin
,
channelPhoneNumber
)
=>
`
You were just made an admin of this Signalboost channel by
${
addingAdmin
}
. Welcome!
You were just made an admin of this Signalboost channel by
${
addingAdmin
}
. Welcome!
...
...
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