Verified Commit 2c2d9da6 authored by aguestuser's avatar aguestuser

[h] relax isolation level in destroy transaction

side-effect: notify members in background in more readable way
parent 30f35ec0
Pipeline #46154 failed with stage
in 51 seconds
const { Transaction } = require('sequelize')
const app = require('../../index')
const phoneNumberRepository = require('../../db/repositories/phoneNumber')
const { defaultLanguage } = require('../../config')
......@@ -18,7 +19,10 @@ const {
// ({phoneNumber: string, sender?: string }) -> SignalboostStatus
const destroy = async ({ phoneNumber, sender }) => {
let tx = await app.db.sequelize.transaction()
let tx = await app.db.sequelize.transaction({
isolationLevel: Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED,
})
try {
const channel = await channelRepository.findDeep(phoneNumber)
const phoneNumberRecord = await phoneNumberRepository.find(phoneNumber)
......@@ -38,13 +42,13 @@ const destroy = async ({ phoneNumber, sender }) => {
await channelRepository.destroy(channel.phoneNumber, tx)
await eventRepository.log(eventTypes.CHANNEL_DESTROYED, phoneNumber, tx)
logger.log(`...deleted channel ${phoneNumber}`)
;(async () => {
logger.log(`sending deletion notice to members of: ${phoneNumber}...`)
await notifier
.notifyMembersExcept(channel, sender, notificationKeys.CHANNEL_DESTROYED)
.catch(logger.error)
logger.log(`...sent deltion notice to members of: ${phoneNumber}`)
})()
// notify members in the background
logger.log(`sending deletion notice to members of: ${phoneNumber}...`)
notifier
.notifyMembersExcept(channel, sender, notificationKeys.CHANNEL_DESTROYED)
.then(() => logger.log(`...sent deltion notice to members of: ${phoneNumber}`))
.catch(logger.error)
}
logger.log(`destroying signald data for ${phoneNumber}...`)
......
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