smal service change
This commit is contained in:
@@ -347,12 +347,18 @@ export class ChatService {
|
|||||||
let relation = await this.findOneRelationshipByUsername(to_block_username, username);
|
let relation = await this.findOneRelationshipByUsername(to_block_username, username);
|
||||||
if (relation)
|
if (relation)
|
||||||
{
|
{
|
||||||
let blocked_friendship = await this.friendshipService.blockFriendship(relation.id, user);
|
await this.friendshipService.blockFriendship(relation.id, user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const newFriendshipDto = {"receiverUsername": to_block_username, "status": FriendshipStatus.BLOCKED};
|
const newFriendshipDto = {"receiverUsername": to_block_username, "status": FriendshipStatus.BLOCKED};
|
||||||
await this.friendshipService.create(newFriendshipDto, user);
|
if (newFriendshipDto)
|
||||||
|
await this.friendshipService.create(newFriendshipDto, user);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printCaller(`throw error: error: true, code: 'BLOCK_USER_FAILED', message: 'we couldn't block the user because it was not found'`);
|
||||||
|
throw new HttpException({ error: true, code: 'BLOCK_USER_FAILED', message: `we couldn't block the user because it was not found` }, HttpStatus.UNAUTHORIZED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printCaller("-- out ");
|
printCaller("-- out ");
|
||||||
@@ -363,8 +369,16 @@ export class ChatService {
|
|||||||
printCaller("-- in ");
|
printCaller("-- in ");
|
||||||
|
|
||||||
let user = await this.getUserByName(username);
|
let user = await this.getUserByName(username);
|
||||||
let relation = await this.findOneRelationshipByUsername(to_unblock_username, username);
|
let relation: SendableFriendship;
|
||||||
await this.friendshipService.removeFriendship(relation.id, user);
|
if (user)
|
||||||
|
relation = await this.findOneRelationshipByUsername(to_unblock_username, username);
|
||||||
|
if (relation)
|
||||||
|
await this.friendshipService.removeFriendship(relation.id, user);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printCaller(`throw error: error: true, code: 'REMOVE_USER_FAILED', message: 'we couldn't unblock the user because it was not found'`);
|
||||||
|
throw new HttpException({ error: true, code: 'REMOVE_USER_FAILED', message: `we couldn't unblock the user because it was not found` }, HttpStatus.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
printCaller("-- out ");
|
printCaller("-- out ");
|
||||||
}
|
}
|
||||||
@@ -373,9 +387,11 @@ export class ChatService {
|
|||||||
{
|
{
|
||||||
printCaller("-- in ");
|
printCaller("-- in ");
|
||||||
|
|
||||||
|
let users: string[] = [];
|
||||||
|
let friends_users: SendableFriendship[];
|
||||||
let user = await this.getUserByName(username);
|
let user = await this.getUserByName(username);
|
||||||
let friends_users = await this.friendshipService.findAllBlockedFriends(user.id);
|
if (user)
|
||||||
let users: string[];
|
friends_users = await this.friendshipService.findAllBlockedFriends(user.id);
|
||||||
if (friends_users)
|
if (friends_users)
|
||||||
users = friends_users.map(user => user.receiverUsername);
|
users = friends_users.map(user => user.receiverUsername);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user