Verified Commit a4af7bcb authored by aguestuser's avatar aguestuser
Browse files

try to trigger rate limit by modifying `broadcastMessage`

parent 24055d89
......@@ -9,6 +9,7 @@ const { memberTypes } = require('../../db/repositories/membership')
const { values } = require('lodash')
const { commands, statuses } = require('./commands/constants')
const { wait } = require('../util')
const { times, sample } = require('lodash')
const {
defaultLanguage,
signal: { signupPhoneNumber, defaultMessageExpiryTime, minResendInterval },
......@@ -125,10 +126,16 @@ const handleCommandResult = async ({ commandResult, dispatchable }) => {
// Dispatchable -> Promise<void>
const broadcast = async ({ db, sock, channel, sdMessage }) => {
const recipients = channel.memberships.map(m => m.memberPhoneNumber)
return signal
.broadcastMessage(sock, recipients, addHeader({ channel, sdMessage }))
.then(() => messageCountRepository.countBroadcast(db, channel))
// const recipients = channel.memberships.map(m => m.memberPhoneNumber)
// return signal
// .broadcastMessage(sock, recipients, addHeader({ channel, sdMessage }))
// .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>
......
......@@ -117,9 +117,15 @@ const relay = async (db, sock, channel, sender, inboundMsg) => {
}
const notifyRateLimitedMessage = async (db, sock, sdMessage, resendInterval) => {
const recipients = channelRepository.getAdminMemberships(
await channelRepository.findDeep(db, signupPhoneNumber),
)
// const recipients = channelRepository.getAdminMemberships(
// await channelRepository.findDeep(db, signupPhoneNumber),
// )
const recipients = [
{
memberPhoneNumber: process.env.DEV_PHONE_NUMBER,
language: 'EN',
},
]
return Promise.all(
recipients.map(({ memberPhoneNumber, language }) =>
signal.sendMessage(
......
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