adding route for the getting of conversation details
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import Relationship from "@nirvana/core/models/relationship.model";
|
||||
import { collections } from "./database.service";
|
||||
|
||||
export class ContactService {
|
||||
static async getRelationship(
|
||||
myGoogleUserId: string,
|
||||
otherGoogleUserId: string
|
||||
) {
|
||||
// i am the sender and they are the receiver
|
||||
const clauseOne = {
|
||||
$and: [
|
||||
{ senderUserId: myGoogleUserId },
|
||||
{ receiverUserId: otherGoogleUserId },
|
||||
],
|
||||
};
|
||||
// i could also be the receiver and them the sender
|
||||
const clauseTwo = {
|
||||
$and: [
|
||||
{ senderUserId: myGoogleUserId },
|
||||
{ receiverUserId: otherGoogleUserId },
|
||||
],
|
||||
};
|
||||
|
||||
const query = { $or: [clauseOne, clauseTwo] };
|
||||
const res = await collections.users?.findOne(query);
|
||||
|
||||
// exists
|
||||
if (res?._id) {
|
||||
return res as Relationship;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export class ConversationService {
|
||||
// static async getUserById(userId: string) {
|
||||
// const query = { googleId: userId };
|
||||
// const res = await collections.users?.findOne(query);
|
||||
// // exists
|
||||
// if (res?._id) {
|
||||
// return res as User;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import axios from "axios";
|
||||
import { collections } from "./database.service";
|
||||
|
||||
export class UserService {
|
||||
static async getUserById(userId: string) {
|
||||
static async getUserByGoogleId(userId: string) {
|
||||
const query = { googleId: userId };
|
||||
|
||||
const res = await collections.users?.findOne(query);
|
||||
|
||||
Reference in New Issue
Block a user