wip
This commit is contained in:
parent
f954b1e276
commit
02ac7d0029
|
@ -545,6 +545,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
// TODO: キャッシュ
|
||||
this.followingsRepository.findBy({
|
||||
followeeId: user.id,
|
||||
isFollowerSuspended: false,
|
||||
notify: 'normal',
|
||||
}).then(async followings => {
|
||||
if (note.visibility !== 'specified') {
|
||||
|
@ -850,6 +851,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
where: {
|
||||
followeeId: user.id,
|
||||
followerHost: IsNull(),
|
||||
isFollowerSuspended: false,
|
||||
isFollowerHibernated: false,
|
||||
},
|
||||
select: ['followerId', 'withReplies'],
|
||||
|
|
|
@ -229,9 +229,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
||||
},
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
||||
},
|
||||
follower: MiUser,
|
||||
silent = false,
|
||||
withReplies?: boolean,
|
||||
): Promise<void> {
|
||||
|
@ -244,6 +242,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
followerId: follower.id,
|
||||
followeeId: followee.id,
|
||||
withReplies: withReplies,
|
||||
isFollowerSuspended: follower.isSuspended,
|
||||
|
||||
// 非正規化
|
||||
followerHost: follower.host,
|
||||
|
@ -734,6 +733,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
return this.followingsRepository.createQueryBuilder('following')
|
||||
.select('following.followeeId')
|
||||
.where('following.followerId = :followerId', { followerId: userId })
|
||||
.andWhere('following.isFollowerSuspended = false')
|
||||
.getMany();
|
||||
}
|
||||
|
||||
|
@ -743,6 +743,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
where: {
|
||||
followerId,
|
||||
followeeId,
|
||||
isFollowerSuspended: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ export class UserSuspendService {
|
|||
});
|
||||
|
||||
(async () => {
|
||||
await this.postSuspend(user).catch(e => {});
|
||||
await this.unFollowAll(user).catch(e => {});
|
||||
await this.postSuspend(user).catch((e: any) => {});
|
||||
await this.unFollowAll(user).catch((e: any) => {});
|
||||
})();
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,8 @@ export class UserSuspendService {
|
|||
});
|
||||
|
||||
(async () => {
|
||||
await this.postUnsuspend(user).catch(e => {});
|
||||
await this.postUnsuspend(user).catch((e: any) => {});
|
||||
await this.restoreFollowings(user).catch((e: any) => {});
|
||||
})();
|
||||
}
|
||||
|
||||
|
@ -140,23 +141,26 @@ export class UserSuspendService {
|
|||
|
||||
@bindThis
|
||||
private async unFollowAll(follower: MiUser) {
|
||||
const followings = await this.followingsRepository.find({
|
||||
where: {
|
||||
await this.followingsRepository.update(
|
||||
{
|
||||
followerId: follower.id,
|
||||
followeeId: Not(IsNull()),
|
||||
},
|
||||
});
|
||||
|
||||
const jobs: RelationshipJobData[] = [];
|
||||
for (const following of followings) {
|
||||
if (following.followeeId && following.followerId) {
|
||||
jobs.push({
|
||||
from: { id: following.followerId },
|
||||
to: { id: following.followeeId },
|
||||
silent: true,
|
||||
});
|
||||
{
|
||||
isFollowerSuspended: true,
|
||||
}
|
||||
}
|
||||
this.queueService.createUnfollowJob(jobs);
|
||||
);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private async restoreFollowings(follower: MiUser) {
|
||||
// フォロー関係を復元(isFollowerSuspended: false)に変更
|
||||
await this.followingsRepository.update(
|
||||
{
|
||||
followerId: follower.id,
|
||||
},
|
||||
{
|
||||
isFollowerSuspended: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ class DeliverManager {
|
|||
where: {
|
||||
followeeId: this.actor.id,
|
||||
followerHost: Not(IsNull()),
|
||||
isFollowerSuspended: false,
|
||||
},
|
||||
select: {
|
||||
followerSharedInbox: true,
|
||||
|
|
|
@ -10,6 +10,8 @@ import { MiUser } from './User.js';
|
|||
@Entity('following')
|
||||
@Index(['followerId', 'followeeId'], { unique: true })
|
||||
@Index(['followeeId', 'followerHost', 'isFollowerHibernated'])
|
||||
@Index(['followeeId', 'followerHost', 'isFollowerSuspended'])
|
||||
@Index(['followerId', 'isFollowerSuspended'])
|
||||
export class MiFollowing {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
@ -45,6 +47,11 @@ export class MiFollowing {
|
|||
})
|
||||
public isFollowerHibernated: boolean;
|
||||
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
})
|
||||
public isFollowerSuspended: boolean;
|
||||
|
||||
// タイムラインにその人のリプライまで含めるかどうか
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
|
|
|
@ -50,7 +50,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.followingsRepository.createQueryBuilder('following'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('following.followeeHost = :host', { host: ps.host });
|
||||
.andWhere('following.followeeHost = :host', { host: ps.host })
|
||||
.andWhere('following.isFollowerSuspended = false');
|
||||
|
||||
const followings = await query
|
||||
.limit(ps.limit)
|
||||
|
|
|
@ -50,7 +50,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.followingsRepository.createQueryBuilder('following'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('following.followerHost = :host', { host: ps.host });
|
||||
.andWhere('following.followerHost = :host', { host: ps.host })
|
||||
.andWhere('following.isFollowerSuspended = false');
|
||||
|
||||
const followings = await query
|
||||
.limit(ps.limit)
|
||||
|
|
|
@ -94,11 +94,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
this.followingsRepository.count({
|
||||
where: {
|
||||
followeeHost: Not(IsNull()),
|
||||
isFollowerSuspended: false,
|
||||
},
|
||||
}),
|
||||
this.followingsRepository.count({
|
||||
where: {
|
||||
followerHost: Not(IsNull()),
|
||||
isFollowerSuspended: false,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
|
|
@ -125,6 +125,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
where: {
|
||||
followeeId: user.id,
|
||||
followerId: me.id,
|
||||
isFollowerSuspended: false,
|
||||
},
|
||||
});
|
||||
if (!isFollowing) {
|
||||
|
@ -136,6 +137,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const query = this.queryService.makePaginationQuery(this.followingsRepository.createQueryBuilder('following'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('following.followeeId = :userId', { userId: user.id })
|
||||
.andWhere('following.isFollowerSuspended = false')
|
||||
.innerJoinAndSelect('following.follower', 'follower');
|
||||
|
||||
const followings = await query
|
||||
|
|
|
@ -133,6 +133,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
where: {
|
||||
followeeId: user.id,
|
||||
followerId: me.id,
|
||||
isFollowerSuspended: false,
|
||||
},
|
||||
});
|
||||
if (!isFollowing) {
|
||||
|
@ -144,6 +145,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const query = this.queryService.makePaginationQuery(this.followingsRepository.createQueryBuilder('following'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.andWhere('following.followerId = :userId', { userId: user.id })
|
||||
.andWhere('following.isFollowerSuspended = false')
|
||||
.innerJoinAndSelect('following.followee', 'followee');
|
||||
|
||||
if (ps.birthday) {
|
||||
|
|
|
@ -68,7 +68,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
const followingQuery = this.followingsRepository.createQueryBuilder('following')
|
||||
.select('following.followeeId')
|
||||
.where('following.followerId = :followerId', { followerId: me.id });
|
||||
.where('following.followerId = :followerId', { followerId: me.id })
|
||||
.andWhere('following.isFollowerSuspended = false');
|
||||
|
||||
query
|
||||
.andWhere(`user.id NOT IN (${ followingQuery.getQuery() })`);
|
||||
|
|
Loading…
Reference in New Issue