Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
2c0bb1b1
Unverified
Commit
2c0bb1b1
authored
1 year ago
by
Diego Sampaio
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
regression: Escape regex for moderation dashboard filters (#29214)
parent
a3417297
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/meteor/app/api/server/v1/moderation.ts
+15
-4
15 additions, 4 deletions
apps/meteor/app/api/server/v1/moderation.ts
with
15 additions
and
4 deletions
apps/meteor/app/api/server/v1/moderation.ts
+
15
−
4
View file @
2c0bb1b1
...
@@ -8,6 +8,7 @@ import {
...
@@ -8,6 +8,7 @@ import {
}
from
'
@rocket.chat/rest-typings
'
;
}
from
'
@rocket.chat/rest-typings
'
;
import
{
ModerationReports
,
Users
,
Messages
}
from
'
@rocket.chat/models
'
;
import
{
ModerationReports
,
Users
,
Messages
}
from
'
@rocket.chat/models
'
;
import
type
{
IModerationReport
}
from
'
@rocket.chat/core-typings
'
;
import
type
{
IModerationReport
}
from
'
@rocket.chat/core-typings
'
;
import
{
escapeRegExp
}
from
'
@rocket.chat/string-helpers
'
;
import
{
API
}
from
'
../api
'
;
import
{
API
}
from
'
../api
'
;
import
{
deleteReportedMessages
}
from
'
../../../../server/lib/moderation/deleteReportedMessages
'
;
import
{
deleteReportedMessages
}
from
'
../../../../server/lib/moderation/deleteReportedMessages
'
;
...
@@ -32,7 +33,9 @@ API.v1.addRoute(
...
@@ -32,7 +33,9 @@ API.v1.addRoute(
const
latest
=
_latest
?
new
Date
(
_latest
)
:
new
Date
();
const
latest
=
_latest
?
new
Date
(
_latest
)
:
new
Date
();
const
oldest
=
_oldest
?
new
Date
(
_oldest
)
:
new
Date
(
0
);
const
oldest
=
_oldest
?
new
Date
(
_oldest
)
:
new
Date
(
0
);
const
reports
=
await
ModerationReports
.
findReportsGroupedByUser
(
latest
,
oldest
,
selector
,
{
offset
,
count
,
sort
}).
toArray
();
const
escapedSelector
=
escapeRegExp
(
selector
);
const
reports
=
await
ModerationReports
.
findReportsGroupedByUser
(
latest
,
oldest
,
escapedSelector
,
{
offset
,
count
,
sort
}).
toArray
();
if
(
reports
.
length
===
0
)
{
if
(
reports
.
length
===
0
)
{
return
API
.
v1
.
success
({
return
API
.
v1
.
success
({
...
@@ -43,7 +46,7 @@ API.v1.addRoute(
...
@@ -43,7 +46,7 @@ API.v1.addRoute(
});
});
}
}
const
total
=
await
ModerationReports
.
countReportsInRange
(
latest
,
oldest
,
s
elector
);
const
total
=
await
ModerationReports
.
countReportsInRange
(
latest
,
oldest
,
escapedS
elector
);
return
API
.
v1
.
success
({
return
API
.
v1
.
success
({
reports
,
reports
,
...
@@ -75,7 +78,13 @@ API.v1.addRoute(
...
@@ -75,7 +78,13 @@ API.v1.addRoute(
return
API
.
v1
.
failure
(
'
error-invalid-user
'
);
return
API
.
v1
.
failure
(
'
error-invalid-user
'
);
}
}
const
{
cursor
,
totalCount
}
=
ModerationReports
.
findReportedMessagesByReportedUserId
(
userId
,
selector
,
{
offset
,
count
,
sort
});
const
escapedSelector
=
escapeRegExp
(
selector
);
const
{
cursor
,
totalCount
}
=
ModerationReports
.
findReportedMessagesByReportedUserId
(
userId
,
escapedSelector
,
{
offset
,
count
,
sort
,
});
const
[
reports
,
total
]
=
await
Promise
.
all
([
cursor
.
toArray
(),
totalCount
]);
const
[
reports
,
total
]
=
await
Promise
.
all
([
cursor
.
toArray
(),
totalCount
]);
...
@@ -203,7 +212,9 @@ API.v1.addRoute(
...
@@ -203,7 +212,9 @@ API.v1.addRoute(
const
{
sort
}
=
await
this
.
parseJsonQuery
();
const
{
sort
}
=
await
this
.
parseJsonQuery
();
const
{
selector
=
''
}
=
this
.
queryParams
;
const
{
selector
=
''
}
=
this
.
queryParams
;
const
{
cursor
,
totalCount
}
=
ModerationReports
.
findReportsByMessageId
(
msgId
,
selector
,
{
count
,
sort
,
offset
});
const
escapedSelector
=
escapeRegExp
(
selector
);
const
{
cursor
,
totalCount
}
=
ModerationReports
.
findReportsByMessageId
(
msgId
,
escapedSelector
,
{
count
,
sort
,
offset
});
const
[
reports
,
total
]
=
await
Promise
.
all
([
cursor
.
toArray
(),
totalCount
]);
const
[
reports
,
total
]
=
await
Promise
.
all
([
cursor
.
toArray
(),
totalCount
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment