add create conv when add friend
This commit is contained in:
parent
c8a26fd297
commit
7d455a342c
@ -14,6 +14,7 @@ import { generate } from 'rxjs';
|
|||||||
import { generateOTP } from './users/2fa';
|
import { generateOTP } from './users/2fa';
|
||||||
import { VerifyOTP } from './users/2fa';
|
import { VerifyOTP } from './users/2fa';
|
||||||
import { ValidateOTP } from './users/2fa';
|
import { ValidateOTP } from './users/2fa';
|
||||||
|
import { privateDecrypt } from 'crypto';
|
||||||
|
|
||||||
|
|
||||||
//2fa
|
//2fa
|
||||||
@ -82,6 +83,27 @@ export class AppController {
|
|||||||
const user = await this.userService.findOne(req.user.username)
|
const user = await this.userService.findOne(req.user.username)
|
||||||
if (!user)
|
if (!user)
|
||||||
return (0);
|
return (0);
|
||||||
|
//create personnal conv for user
|
||||||
|
//await this.userService.addFriend(user, data.username);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const amIhere = data.members.includes(req.user.username);
|
||||||
|
// if (!amIhere)
|
||||||
|
const conv = {
|
||||||
|
id: null,
|
||||||
|
name: req.user.username + ", " + data.username,
|
||||||
|
banned: null,
|
||||||
|
admin: null,
|
||||||
|
messages: null,
|
||||||
|
members: [],
|
||||||
|
owner: req.user.username,
|
||||||
|
group: false,
|
||||||
|
};
|
||||||
|
conv.members.push(req.user.username);
|
||||||
|
conv.members.push(data.username);
|
||||||
|
await this.chatService.createConv(conv);
|
||||||
|
|
||||||
return await this.userService.addFriend(user, data.username);
|
return await this.userService.addFriend(user, data.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +390,7 @@ export class AppController {
|
|||||||
data.members.push(req.user.username)
|
data.members.push(req.user.username)
|
||||||
// let test = {id: 2, members: "cc"};
|
// let test = {id: 2, members: "cc"};
|
||||||
data.owner = req.user.username
|
data.owner = req.user.username
|
||||||
|
data.group = true;
|
||||||
return await this.chatService.createConv(data);
|
return await this.chatService.createConv(data);
|
||||||
// res.json(messages);
|
// res.json(messages);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user