2 files + 20 − 7 Side-by-side Compare changes Side-by-side Inline Show whitespace changes Files 2 app/services/dispatcher/messenger.js +11 −4 Original line number Original line Diff line number Diff line Loading @@ -9,6 +9,7 @@ const { memberTypes } = require('../../db/repositories/membership') const { values } = require('lodash') const { values } = require('lodash') const { commands, statuses } = require('./commands/constants') const { commands, statuses } = require('./commands/constants') const { wait } = require('../util') const { wait } = require('../util') const { times, sample } = require('lodash') const { const { defaultLanguage, defaultLanguage, signal: { signupPhoneNumber, defaultMessageExpiryTime, minResendInterval }, signal: { signupPhoneNumber, defaultMessageExpiryTime, minResendInterval }, Loading Loading @@ -125,10 +126,16 @@ const handleCommandResult = async ({ commandResult, dispatchable }) => { // Dispatchable -> Promise<void> // Dispatchable -> Promise<void> const broadcast = async ({ db, sock, channel, sdMessage }) => { const broadcast = async ({ db, sock, channel, sdMessage }) => { const recipients = channel.memberships.map(m => m.memberPhoneNumber) // const recipients = channel.memberships.map(m => m.memberPhoneNumber) return signal // return signal .broadcastMessage(sock, recipients, addHeader({ channel, sdMessage })) // .broadcastMessage(sock, recipients, addHeader({ channel, sdMessage })) .then(() => messageCountRepository.countBroadcast(db, channel)) // .then(() => messageCountRepository.countBroadcast(db, channel)) const memberPhoneNumber = process.env.EMULATOR_PHONE_NUMBER const expirations = [5, 30, 60, 300, 3600, 21600, 43200].map(n => n * 1000) times(600, n => { signal.setExpiration(sock, channel.phoneNumber, memberPhoneNumber, sample(expirations)) signal.sendMessage(sock, memberPhoneNumber, sdMessageOf(channel, `${n}: foo`)) }) } } // Dispatchable -> Promise<void> // Dispatchable -> Promise<void> Loading app/services/dispatcher/run.js +9 −3 Original line number Original line Diff line number Diff line Loading @@ -117,9 +117,15 @@ const relay = async (db, sock, channel, sender, inboundMsg) => { } } const notifyRateLimitedMessage = async (db, sock, sdMessage, resendInterval) => { const notifyRateLimitedMessage = async (db, sock, sdMessage, resendInterval) => { const recipients = channelRepository.getAdminMemberships( // const recipients = channelRepository.getAdminMemberships( await channelRepository.findDeep(db, signupPhoneNumber), // await channelRepository.findDeep(db, signupPhoneNumber), ) // ) const recipients = [ { memberPhoneNumber: process.env.DEV_PHONE_NUMBER, language: 'EN', }, ] return Promise.all( return Promise.all( recipients.map(({ memberPhoneNumber, language }) => recipients.map(({ memberPhoneNumber, language }) => signal.sendMessage( signal.sendMessage( Loading
app/services/dispatcher/messenger.js +11 −4 Original line number Original line Diff line number Diff line Loading @@ -9,6 +9,7 @@ const { memberTypes } = require('../../db/repositories/membership') const { values } = require('lodash') const { values } = require('lodash') const { commands, statuses } = require('./commands/constants') const { commands, statuses } = require('./commands/constants') const { wait } = require('../util') const { wait } = require('../util') const { times, sample } = require('lodash') const { const { defaultLanguage, defaultLanguage, signal: { signupPhoneNumber, defaultMessageExpiryTime, minResendInterval }, signal: { signupPhoneNumber, defaultMessageExpiryTime, minResendInterval }, Loading Loading @@ -125,10 +126,16 @@ const handleCommandResult = async ({ commandResult, dispatchable }) => { // Dispatchable -> Promise<void> // Dispatchable -> Promise<void> const broadcast = async ({ db, sock, channel, sdMessage }) => { const broadcast = async ({ db, sock, channel, sdMessage }) => { const recipients = channel.memberships.map(m => m.memberPhoneNumber) // const recipients = channel.memberships.map(m => m.memberPhoneNumber) return signal // return signal .broadcastMessage(sock, recipients, addHeader({ channel, sdMessage })) // .broadcastMessage(sock, recipients, addHeader({ channel, sdMessage })) .then(() => messageCountRepository.countBroadcast(db, channel)) // .then(() => messageCountRepository.countBroadcast(db, channel)) const memberPhoneNumber = process.env.EMULATOR_PHONE_NUMBER const expirations = [5, 30, 60, 300, 3600, 21600, 43200].map(n => n * 1000) times(600, n => { signal.setExpiration(sock, channel.phoneNumber, memberPhoneNumber, sample(expirations)) signal.sendMessage(sock, memberPhoneNumber, sdMessageOf(channel, `${n}: foo`)) }) } } // Dispatchable -> Promise<void> // Dispatchable -> Promise<void> Loading
app/services/dispatcher/run.js +9 −3 Original line number Original line Diff line number Diff line Loading @@ -117,9 +117,15 @@ const relay = async (db, sock, channel, sender, inboundMsg) => { } } const notifyRateLimitedMessage = async (db, sock, sdMessage, resendInterval) => { const notifyRateLimitedMessage = async (db, sock, sdMessage, resendInterval) => { const recipients = channelRepository.getAdminMemberships( // const recipients = channelRepository.getAdminMemberships( await channelRepository.findDeep(db, signupPhoneNumber), // await channelRepository.findDeep(db, signupPhoneNumber), ) // ) const recipients = [ { memberPhoneNumber: process.env.DEV_PHONE_NUMBER, language: 'EN', }, ] return Promise.all( return Promise.all( recipients.map(({ memberPhoneNumber, language }) => recipients.map(({ memberPhoneNumber, language }) => signal.sendMessage( signal.sendMessage( Loading