mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 04:09:26 +00:00
feat: show pending messages in appbar
This commit is contained in:
@@ -13,12 +13,14 @@ exports.index = async (req, res) => {
|
||||
status = "",
|
||||
date = "",
|
||||
searchParam = "",
|
||||
showAll,
|
||||
} = req.query;
|
||||
|
||||
const userId = req.userId;
|
||||
|
||||
const limit = 20;
|
||||
const offset = limit * (pageNumber - 1);
|
||||
|
||||
let whereCondition = {};
|
||||
let includeCondition = [
|
||||
{
|
||||
model: Contact,
|
||||
@@ -27,16 +29,20 @@ exports.index = async (req, res) => {
|
||||
},
|
||||
];
|
||||
|
||||
let whereCondition = { userId: userId };
|
||||
|
||||
if (showAll === "true") {
|
||||
whereCondition = {};
|
||||
}
|
||||
|
||||
if (status) {
|
||||
whereCondition = {
|
||||
...whereCondition,
|
||||
status: status,
|
||||
};
|
||||
}
|
||||
// else if (status === "closed") {
|
||||
// whereCondition = { ...whereCondition, status: "closed" };
|
||||
// }
|
||||
else if (searchParam) {
|
||||
|
||||
if (searchParam) {
|
||||
includeCondition = [
|
||||
...includeCondition,
|
||||
{
|
||||
@@ -56,7 +62,6 @@ exports.index = async (req, res) => {
|
||||
];
|
||||
|
||||
whereCondition = {
|
||||
...whereCondition,
|
||||
[Sequelize.Op.or]: [
|
||||
{
|
||||
"$contact.name$": Sequelize.where(
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = async (req, res, next) => {
|
||||
if (error) {
|
||||
return res.status(401).json({ error: "Invalid token" });
|
||||
}
|
||||
req.userId = token.userId;
|
||||
req.userId = result.userId;
|
||||
// todo >> find user in DB and store in req.user to use latter, or throw an error if user not exists anymore
|
||||
next();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user