|
@@ -149,6 +149,25 @@ const muteChat = async (req, res, next) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const sortChat = async (req, res, next) => {
|
|
|
+ try {
|
|
|
+ const id = req.body.id;
|
|
|
+ const userId = req.user.id;
|
|
|
+ const isChat = await ChatModel.getByField(id, userId);
|
|
|
+ if (isChat) {
|
|
|
+ const { _id, sort } = isChat;
|
|
|
+ await ChatModel.update(_id, { sort: !sort });
|
|
|
+ return res.status(200).json({
|
|
|
+ status: 'success',
|
|
|
+ code: 200,
|
|
|
+ data: {},
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ next(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const seenChat = async (req, res, next) => {
|
|
|
try {
|
|
|
const id = req.body.id;
|
|
@@ -202,6 +221,7 @@ const chatById = async (req, res, next) => {
|
|
|
avatarUrl,
|
|
|
color,
|
|
|
mute,
|
|
|
+ sort,
|
|
|
seen,
|
|
|
total,
|
|
|
watched,
|
|
@@ -224,6 +244,7 @@ const chatById = async (req, res, next) => {
|
|
|
color,
|
|
|
online,
|
|
|
mute,
|
|
|
+ sort,
|
|
|
seen,
|
|
|
total,
|
|
|
watched,
|
|
@@ -247,6 +268,7 @@ module.exports = {
|
|
|
listChats,
|
|
|
startChat,
|
|
|
muteChat,
|
|
|
+ sortChat,
|
|
|
seenChat,
|
|
|
typingChat,
|
|
|
chatById,
|