wip
This commit is contained in:
parent
37ee6ec9a8
commit
3e200c0f66
|
@ -67,8 +67,15 @@ export class ChatService {
|
||||||
if (toUser.chatScope === 'none') {
|
if (toUser.chatScope === 'none') {
|
||||||
throw new Error('recipient is cannot chat');
|
throw new Error('recipient is cannot chat');
|
||||||
} else if (toUser.chatScope === 'followers') {
|
} else if (toUser.chatScope === 'followers') {
|
||||||
|
const isFollower = await this.userFollowingService.isFollowing(fromUser.id, toUser.id);
|
||||||
|
if (!isFollower) {
|
||||||
|
throw new Error('recipient is cannot chat');
|
||||||
|
}
|
||||||
} else if (toUser.chatScope === 'following') {
|
} else if (toUser.chatScope === 'following') {
|
||||||
|
const isFollowing = await this.userFollowingService.isFollowing(toUser.id, fromUser.id);
|
||||||
|
if (!isFollowing) {
|
||||||
|
throw new Error('recipient is cannot chat');
|
||||||
|
}
|
||||||
} else if (toUser.chatScope === 'mutual') {
|
} else if (toUser.chatScope === 'mutual') {
|
||||||
const isMutual = await this.userFollowingService.isMutual(fromUser.id, toUser.id);
|
const isMutual = await this.userFollowingService.isMutual(fromUser.id, toUser.id);
|
||||||
if (!isMutual) {
|
if (!isMutual) {
|
||||||
|
|
|
@ -737,6 +737,16 @@ export class UserFollowingService implements OnModuleInit {
|
||||||
.getMany();
|
.getMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public isFollowing(followerId: MiUser['id'], followeeId: MiUser['id']) {
|
||||||
|
return this.followingsRepository.exists({
|
||||||
|
where: {
|
||||||
|
followerId,
|
||||||
|
followeeId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async isMutual(aUserId: MiUser['id'], bUserId: MiUser['id']) {
|
public async isMutual(aUserId: MiUser['id'], bUserId: MiUser['id']) {
|
||||||
const count = await this.followingsRepository.createQueryBuilder('following')
|
const count = await this.followingsRepository.createQueryBuilder('following')
|
||||||
|
|
Loading…
Reference in New Issue