名前の変更と変更不要の差分をロールバック
This commit is contained in:
parent
a56c680136
commit
b5ccf1b484
|
@ -15,7 +15,7 @@ import { RedisKVCache } from '@/misc/cache.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ChannelMutingService {
|
export class ChannelMutingService {
|
||||||
public userMutingChannelsCache: RedisKVCache<Set<string>>;
|
public mutingChannelsCache: RedisKVCache<Set<string>>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.redis)
|
@Inject(DI.redis)
|
||||||
|
@ -29,7 +29,7 @@ export class ChannelMutingService {
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
this.userMutingChannelsCache = new RedisKVCache<Set<string>>(this.redisClient, 'channelMutingChannels', {
|
this.mutingChannelsCache = new RedisKVCache<Set<string>>(this.redisClient, 'channelMutingChannels', {
|
||||||
lifetime: 1000 * 60 * 30, // 30m
|
lifetime: 1000 * 60 * 30, // 30m
|
||||||
memoryCacheLifetime: 1000 * 60, // 1m
|
memoryCacheLifetime: 1000 * 60, // 1m
|
||||||
fetcher: (userId) => this.channelMutingRepository.find({
|
fetcher: (userId) => this.channelMutingRepository.find({
|
||||||
|
@ -115,7 +115,7 @@ export class ChannelMutingService {
|
||||||
requestUserId: MiUser['id'],
|
requestUserId: MiUser['id'],
|
||||||
targetChannelId: MiChannel['id'],
|
targetChannelId: MiChannel['id'],
|
||||||
}): Promise<boolean> {
|
}): Promise<boolean> {
|
||||||
const mutedChannels = await this.userMutingChannelsCache.get(params.requestUserId);
|
const mutedChannels = await this.mutingChannelsCache.get(params.requestUserId);
|
||||||
return (mutedChannels?.has(params.targetChannelId) ?? false);
|
return (mutedChannels?.has(params.targetChannelId) ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ export class ChannelMutingService {
|
||||||
|
|
||||||
const userIds = [...new Set(expiredMutings.map(x => x.userId))];
|
const userIds = [...new Set(expiredMutings.map(x => x.userId))];
|
||||||
for (const userId of userIds) {
|
for (const userId of userIds) {
|
||||||
this.userMutingChannelsCache.refresh(userId).then();
|
this.mutingChannelsCache.refresh(userId).then();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,11 +185,11 @@ export class ChannelMutingService {
|
||||||
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'muteChannel': {
|
case 'muteChannel': {
|
||||||
this.userMutingChannelsCache.refresh(body.userId).then();
|
this.mutingChannelsCache.refresh(body.userId).then();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'unmuteChannel': {
|
case 'unmuteChannel': {
|
||||||
this.userMutingChannelsCache.delete(body.userId).then();
|
this.mutingChannelsCache.delete(body.userId).then();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ export class ChannelMutingService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this.userMutingChannelsCache.dispose();
|
this.mutingChannelsCache.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
|
@ -111,7 +111,7 @@ export class FanoutTimelineEndpointService {
|
||||||
this.cacheService.renoteMutingsCache.fetch(ps.me.id),
|
this.cacheService.renoteMutingsCache.fetch(ps.me.id),
|
||||||
this.cacheService.userBlockedCache.fetch(ps.me.id),
|
this.cacheService.userBlockedCache.fetch(ps.me.id),
|
||||||
this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)),
|
this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)),
|
||||||
ps.excludeMutedChannels ? this.channelMutingService.userMutingChannelsCache.fetch(me.id) : Promise.resolve(new Set<string>()),
|
ps.excludeMutedChannels ? this.channelMutingService.mutingChannelsCache.fetch(me.id) : Promise.resolve(new Set<string>()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const parentFilter = filter;
|
const parentFilter = filter;
|
||||||
|
|
|
@ -39,7 +39,6 @@ export default class Connection {
|
||||||
public userIdsWhoBlockingMe: Set<string> = new Set();
|
public userIdsWhoBlockingMe: Set<string> = new Set();
|
||||||
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
|
public userIdsWhoMeMutingRenotes: Set<string> = new Set();
|
||||||
public userMutedInstances: Set<string> = new Set();
|
public userMutedInstances: Set<string> = new Set();
|
||||||
public userMutedChannels: Set<string> = new Set();
|
|
||||||
private fetchIntervalId: NodeJS.Timeout | null = null;
|
private fetchIntervalId: NodeJS.Timeout | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -71,7 +70,7 @@ export default class Connection {
|
||||||
this.cacheService.userProfileCache.fetch(this.user.id),
|
this.cacheService.userProfileCache.fetch(this.user.id),
|
||||||
this.cacheService.userFollowingsCache.fetch(this.user.id),
|
this.cacheService.userFollowingsCache.fetch(this.user.id),
|
||||||
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
|
this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id),
|
||||||
this.channelMutingService.userMutingChannelsCache.fetch(this.user.id),
|
this.channelMutingService.mutingChannelsCache.fetch(this.user.id),
|
||||||
this.cacheService.userMutingsCache.fetch(this.user.id),
|
this.cacheService.userMutingsCache.fetch(this.user.id),
|
||||||
this.cacheService.userBlockedCache.fetch(this.user.id),
|
this.cacheService.userBlockedCache.fetch(this.user.id),
|
||||||
this.cacheService.renoteMutingsCache.fetch(this.user.id),
|
this.cacheService.renoteMutingsCache.fetch(this.user.id),
|
||||||
|
@ -125,37 +124,16 @@ export default class Connection {
|
||||||
const { type, body } = obj;
|
const { type, body } = obj;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'readNotification':
|
case 'readNotification': this.onReadNotification(body); break;
|
||||||
this.onReadNotification(body);
|
case 'subNote': this.onSubscribeNote(body); break;
|
||||||
break;
|
case 's': this.onSubscribeNote(body); break; // alias
|
||||||
case 'subNote':
|
case 'sr': this.onSubscribeNote(body); this.readNote(body); break;
|
||||||
this.onSubscribeNote(body);
|
case 'unsubNote': this.onUnsubscribeNote(body); break;
|
||||||
break;
|
case 'un': this.onUnsubscribeNote(body); break; // alias
|
||||||
case 's':
|
case 'connect': this.onChannelConnectRequested(body); break;
|
||||||
this.onSubscribeNote(body);
|
case 'disconnect': this.onChannelDisconnectRequested(body); break;
|
||||||
break; // alias
|
case 'channel': this.onChannelMessageRequested(body); break;
|
||||||
case 'sr':
|
case 'ch': this.onChannelMessageRequested(body); break; // alias
|
||||||
this.onSubscribeNote(body);
|
|
||||||
this.readNote(body);
|
|
||||||
break;
|
|
||||||
case 'unsubNote':
|
|
||||||
this.onUnsubscribeNote(body);
|
|
||||||
break;
|
|
||||||
case 'un':
|
|
||||||
this.onUnsubscribeNote(body);
|
|
||||||
break; // alias
|
|
||||||
case 'connect':
|
|
||||||
this.onChannelConnectRequested(body);
|
|
||||||
break;
|
|
||||||
case 'disconnect':
|
|
||||||
this.onChannelDisconnectRequested(body);
|
|
||||||
break;
|
|
||||||
case 'channel':
|
|
||||||
this.onChannelMessageRequested(body);
|
|
||||||
break;
|
|
||||||
case 'ch':
|
|
||||||
this.onChannelMessageRequested(body);
|
|
||||||
break; // alias
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class HybridTimelineChannel extends Channel {
|
||||||
(note.channelId == null && Object.hasOwn(this.following, note.userId)) ||
|
(note.channelId == null && Object.hasOwn(this.following, note.userId)) ||
|
||||||
(note.channelId == null && (note.user.host == null && note.visibility === 'public')) ||
|
(note.channelId == null && (note.user.host == null && note.visibility === 'public')) ||
|
||||||
(note.channelId != null && this.followingChannels.has(note.channelId)) ||
|
(note.channelId != null && this.followingChannels.has(note.channelId)) ||
|
||||||
(note.channelId != null && !isChannelRelated(note, this.mutingChannels))
|
(note.channelId != null && isChannelRelated(note, this.mutingChannels))
|
||||||
)) return;
|
)) return;
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (note.visibility === 'followers') {
|
||||||
|
|
Loading…
Reference in New Issue