1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Don't notify on muted instance

This commit is contained in:
Chocobozzz 2019-12-19 10:35:47 +01:00
parent 96f6278f3e
commit dddc8b1fe0
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 262 additions and 19 deletions

View file

@ -75,11 +75,6 @@ export class AccountBlocklistModel extends Model<AccountBlocklistModel> {
})
BlockedAccount: AccountModel
static isAccountMutedBy (accountId: number, targetAccountId: number) {
return AccountBlocklistModel.isAccountMutedByMulti([ accountId ], targetAccountId)
.then(result => result[accountId])
}
static isAccountMutedByMulti (accountIds: number[], targetAccountId: number) {
const query = {
attributes: [ 'accountId', 'id' ],

View file

@ -5,6 +5,7 @@ import { ServerBlock } from '../../../shared/models/blocklist'
import { getSort } from '../utils'
import * as Bluebird from 'bluebird'
import { MServerBlocklist, MServerBlocklistAccountServer, MServerBlocklistFormattable } from '@server/typings/models'
import { Op } from 'sequelize'
enum ScopeNames {
WITH_ACCOUNT = 'WITH_ACCOUNT',
@ -75,6 +76,31 @@ export class ServerBlocklistModel extends Model<ServerBlocklistModel> {
})
BlockedServer: ServerModel
static isServerMutedByMulti (accountIds: number[], targetServerId: number) {
const query = {
attributes: [ 'accountId', 'id' ],
where: {
accountId: {
[Op.in]: accountIds // FIXME: sequelize ANY seems broken
},
targetServerId
},
raw: true
}
return ServerBlocklistModel.unscoped()
.findAll(query)
.then(rows => {
const result: { [accountId: number]: boolean } = {}
for (const accountId of accountIds) {
result[accountId] = !!rows.find(r => r.accountId === accountId)
}
return result
})
}
static loadByAccountAndHost (accountId: number, host: string): Bluebird<MServerBlocklist> {
const query = {
where: {