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