mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
improvement: trim search params on contacts and tickets filters
This commit is contained in:
@@ -20,8 +20,6 @@ interface Response {
|
||||
export const RefreshTokenService = async (token: string): Promise<Response> => {
|
||||
let decoded;
|
||||
|
||||
console.log(token);
|
||||
|
||||
try {
|
||||
decoded = verify(token, authConfig.refreshSecret);
|
||||
} catch (err) {
|
||||
|
||||
@@ -22,10 +22,10 @@ const ListContactsService = async ({
|
||||
name: Sequelize.where(
|
||||
Sequelize.fn("LOWER", Sequelize.col("name")),
|
||||
"LIKE",
|
||||
`%${searchParam.toLowerCase()}%`
|
||||
`%${searchParam.toLowerCase().trim()}%`
|
||||
)
|
||||
},
|
||||
{ number: { [Op.like]: `%${searchParam}%` } }
|
||||
{ number: { [Op.like]: `%${searchParam.toLowerCase().trim()}%` } }
|
||||
]
|
||||
};
|
||||
const limit = 20;
|
||||
|
||||
@@ -55,6 +55,8 @@ const ListTicketsService = async ({
|
||||
}
|
||||
|
||||
if (searchParam) {
|
||||
const sanitizedSearchParam = searchParam.toLocaleLowerCase().trim();
|
||||
|
||||
includeCondition = [
|
||||
...includeCondition,
|
||||
{
|
||||
@@ -65,7 +67,7 @@ const ListTicketsService = async ({
|
||||
body: where(
|
||||
fn("LOWER", col("body")),
|
||||
"LIKE",
|
||||
`%${searchParam.toLowerCase()}%`
|
||||
`%${sanitizedSearchParam}%`
|
||||
)
|
||||
},
|
||||
required: false,
|
||||
@@ -79,15 +81,15 @@ const ListTicketsService = async ({
|
||||
"$contact.name$": where(
|
||||
fn("LOWER", col("name")),
|
||||
"LIKE",
|
||||
`%${searchParam.toLowerCase()}%`
|
||||
`%${sanitizedSearchParam}%`
|
||||
)
|
||||
},
|
||||
{ "$contact.number$": { [Op.like]: `%${searchParam}%` } },
|
||||
{ "$contact.number$": { [Op.like]: `%${sanitizedSearchParam}%` } },
|
||||
{
|
||||
"$message.body$": where(
|
||||
fn("LOWER", col("body")),
|
||||
"LIKE",
|
||||
`%${searchParam.toLowerCase()}%`
|
||||
`%${sanitizedSearchParam}%`
|
||||
)
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user