don't mute users who are already followed
This commit is contained in:
parent
be3c911e48
commit
5003557e90
1 changed files with 7 additions and 3 deletions
|
|
@ -201,9 +201,12 @@ export class AccountMoveService {
|
||||||
if (oldMutings.length === 0) return;
|
if (oldMutings.length === 0) return;
|
||||||
|
|
||||||
// Check if the destination account is already indefinitely muted by the muter
|
// Check if the destination account is already indefinitely muted by the muter
|
||||||
const existingMutingsMuterUserIds = await this.mutingsRepository.findBy(
|
const [existingMutingsMuterUserIds, dstFollowers] = await Promise.all([
|
||||||
{ muteeId: dst.id, expiresAt: IsNull() },
|
this.mutingsRepository.findBy(
|
||||||
).then(mutings => mutings.map(muting => muting.muterId));
|
{ muteeId: dst.id, expiresAt: IsNull() },
|
||||||
|
).then(mutings => mutings.map(muting => muting.muterId)),
|
||||||
|
this.cacheService.userFollowersCache.fetch(dst.id),
|
||||||
|
]);
|
||||||
|
|
||||||
const newMutings: Map<string, { muterId: string; muteeId: string; expiresAt: Date | null; }> = new Map();
|
const newMutings: Map<string, { muterId: string; muteeId: string; expiresAt: Date | null; }> = new Map();
|
||||||
|
|
||||||
|
|
@ -217,6 +220,7 @@ export class AccountMoveService {
|
||||||
};
|
};
|
||||||
for (const muting of oldMutings) {
|
for (const muting of oldMutings) {
|
||||||
if (existingMutingsMuterUserIds.includes(muting.muterId)) continue; // skip if already muted indefinitely
|
if (existingMutingsMuterUserIds.includes(muting.muterId)) continue; // skip if already muted indefinitely
|
||||||
|
if (dstFollowers.has(muting.muterId)) continue; // skip if already following
|
||||||
newMutings.set(genId(), {
|
newMutings.set(genId(), {
|
||||||
...muting,
|
...muting,
|
||||||
muteeId: dst.id,
|
muteeId: dst.id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue