Verified Commit 46e04eda authored by aguestuser's avatar aguestuser
Browse files

[102] make signup request messages disappear within 1 day

parent 0c49349b
......@@ -43,7 +43,7 @@ Reply with HELP for more information or GOODBYE to leave.`,
signupRequestReceived: (senderNumber, requestMsg) =>
`Signup request received from ${senderNumber}:\n ${requestMsg}`,
signupRequestResponse:
'Thank you for signing up for Signalboost! We are creating a channel for you!\n We will send you a welcome message on your channel shortly...',
'Thank you for signing up for Signalboost!\n You will receive a welcome message on your new channel shortly...',
}
const commandResponses = {
......
......@@ -49,14 +49,22 @@ const dispatch = async ({ commandResult, dispatchable }) => {
}
const handleSignupMessage = async ({ sock, channel, sender, sdMessage }) => {
// TODO: set disappearing messages here
const notifications = messagesIn(defaultLanguage).notifications
const oneDay = 60 * 60 * 24
// set expiry
await Promise.all(
channel.publications.map(p =>
signal.setExpiration(sock, channel.phoneNumber, p.publisherPhoneNumber, oneDay),
),
)
// notify admins of signpu request
await notify({
sock,
channel,
notification: notifications.signupRequestReceived(sender.phoneNumber, sdMessage.messageBody),
recipients: channel.publications.map(p => p.publisherPhoneNumber),
})
// respond to signpu requester
return notify({
sock,
channel,
......
......@@ -86,6 +86,7 @@ const messageTypes = {
VERIFICATION_SUCCESS: 'verification_succeeded',
VERIFICATION_ERROR: 'verification_error',
VERIFICATION_REQUIRED: 'verification_required',
SET_EXPIRATION: 'set_expiration',
}
const trustLevels = {
......@@ -218,6 +219,14 @@ const broadcastMessage = (sock, recipientNumbers, outboundMessage) =>
recipientNumbers.map(recipientNumber => sendMessage(sock, recipientNumber, outboundMessage)),
)
const setExpiration = (sock, channelPhoneNumber, memberPhoneNumber, expiresInSeconds) =>
write(sock, {
type: messageTypes.SET_EXPIRATION,
username: channelPhoneNumber,
recipientNumber: memberPhoneNumber,
expiresInSeconds,
})
// (Socket, String, String) -> Promise<Array<TrustResult>>
const trust = async (sock, channelPhoneNumber, memberPhoneNumber) => {
const id = await fetchMostRecentId(sock, channelPhoneNumber, memberPhoneNumber)
......@@ -356,4 +365,5 @@ module.exports = {
subscribe,
trust,
verify,
setExpiration,
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment