more junk from core
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { JwtClaims, authCheck } from "../middleware/auth";
|
import { JwtClaims, authCheck } from '../middleware/auth';
|
||||||
import express, { Application, Request, Response } from "express";
|
import express, { Application, Request, Response } from 'express';
|
||||||
|
|
||||||
import { User } from "@nirvana/core/models";
|
import User from '@nirvana/core/models/user.model';
|
||||||
import UserSearchResponse from "../../core/responses/userSearch.response";
|
import UserSearchResponse from '../../core/responses/userSearch.response';
|
||||||
import { UserService } from "../services/user.service";
|
import { UserService } from '../services/user.service';
|
||||||
|
|
||||||
export default function getSearchRoutes() {
|
export default function getSearchRoutes() {
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
@@ -11,7 +11,7 @@ export default function getSearchRoutes() {
|
|||||||
router.use(express.json());
|
router.use(express.json());
|
||||||
|
|
||||||
// get user details based on id token
|
// get user details based on id token
|
||||||
router.get("/users", authCheck, handleUserSearch);
|
router.get('/users', authCheck, handleUserSearch);
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
@@ -23,18 +23,14 @@ async function handleUserSearch(req: Request, res: Response) {
|
|||||||
const { query } = req.query;
|
const { query } = req.query;
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
res.status(400).send("No search query provided!");
|
res.status(400).send('No search query provided!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// text search on users
|
// text search on users
|
||||||
const users: User[] | null = await UserService.getUsersLikeEmailAndName(
|
const users: User[] | null = await UserService.getUsersLikeEmailAndName(query as string);
|
||||||
query as string
|
|
||||||
);
|
|
||||||
|
|
||||||
const filteredUsers = users?.filter(
|
const filteredUsers = users?.filter((currUser) => currUser._id?.toString() !== userInfo.userId);
|
||||||
(currUser) => currUser._id?.toString() !== userInfo.userId
|
|
||||||
);
|
|
||||||
|
|
||||||
const resObj = new UserSearchResponse(filteredUsers ?? []);
|
const resObj = new UserSearchResponse(filteredUsers ?? []);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import User, { GoogleUserInfo } from '@nirvana/core/models/user.model';
|
import User, { GoogleUserInfo, UserStatus } from '@nirvana/core/models/user.model';
|
||||||
|
|
||||||
import { ObjectId } from 'mongodb';
|
import { ObjectId } from 'mongodb';
|
||||||
import { UserStatus } from '../../core/models/user.model';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { collections } from './database.service';
|
import { collections } from './database.service';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export default class ErrorResponse {
|
|
||||||
status: number;
|
|
||||||
message: string;
|
|
||||||
detail: string;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import Relationship from "../models/relationship.model";
|
|
||||||
import { User } from "../models/user.model";
|
|
||||||
|
|
||||||
export default class GetContactsResponse {
|
|
||||||
contactsDetails: ContactDetails[] = [];
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ContactDetails {
|
|
||||||
isSpeaking: boolean = false;
|
|
||||||
|
|
||||||
constructor(public otherUser: User, public relationship: Relationship) {}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import Content from "../models/content.model";
|
|
||||||
import Relationship from "../models/relationship.model";
|
|
||||||
import { User } from "@nirvana/core/models";
|
|
||||||
|
|
||||||
export default class GetConversationDetailsResponse {
|
|
||||||
// get the messages for this conversation for like last 7 days or just a count of them until we paginate?
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
public contactUser: User,
|
|
||||||
public isLiveOrPinned: boolean,
|
|
||||||
public ourRelationship?: Relationship,
|
|
||||||
public latestContent?: Content[]
|
|
||||||
) {}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { Line } from "../models/line.model";
|
|
||||||
|
|
||||||
export default class GetDmConversationByOtherUserIdResponse {
|
|
||||||
constructor(public conversation: Conversation) {}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { Line } from "../models/line.model";
|
|
||||||
import MasterLineData from "../models/masterLineData.model";
|
|
||||||
|
|
||||||
export default class GetUserLinesResponse {
|
|
||||||
constructor(public masterLines: MasterLineData[]) {}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { User } from "../models/user.model";
|
import User from '../models/user.model';
|
||||||
|
|
||||||
export default class LoginResponse {
|
export default class LoginResponse {
|
||||||
constructor(public jwtToken: string, public userDetails: User) {}
|
constructor(public jwtToken: string, public userDetails: User) {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { User } from "@nirvana/core/models";
|
import User from '../models/user.model';
|
||||||
|
|
||||||
export default class UserDetailsResponse {
|
export default class UserDetailsResponse {
|
||||||
constructor(public user: User) {}
|
constructor(public user: User) {}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { User } from "@nirvana/core/models";
|
import User from '../models/user.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full results from the global search
|
* Full results from the global search
|
||||||
*/
|
*/
|
||||||
export default class UserSearchResponse {
|
export default class UserSearchResponse {
|
||||||
// all friends/contacts matching search
|
|
||||||
contacts?: User[];
|
|
||||||
|
|
||||||
// all public users
|
// all public users
|
||||||
constructor(public users: User[]) {}
|
constructor(public users: User[]) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user