fix report username filter
All checks were successful
deploy / build-and-deploy (push) Successful in 22s
All checks were successful
deploy / build-and-deploy (push) Successful in 22s
This commit is contained in:
@@ -94,23 +94,6 @@ export async function getReports(db: Database, values: GetReportsReq) {
|
||||
const reporter = alias(user, 'reporter');
|
||||
const reported = alias(user, 'reported');
|
||||
|
||||
let reporterIdSubquery;
|
||||
if (values.reporter != null) {
|
||||
reporterIdSubquery = db
|
||||
.select({ id: reporter.id })
|
||||
.from(reporter)
|
||||
.where(eq(reporter.username, values.reporter))
|
||||
.as('reporter_id_subquery');
|
||||
}
|
||||
let reportedIdSubquery;
|
||||
if (values.reported != null) {
|
||||
reportedIdSubquery = db
|
||||
.select({ id: reported.id })
|
||||
.from(reported)
|
||||
.where(eq(reported.username, values.reported))
|
||||
.as('reported_id_subquery');
|
||||
}
|
||||
|
||||
return db
|
||||
.select({
|
||||
id: report.id,
|
||||
@@ -145,8 +128,8 @@ export async function getReports(db: Database, values: GetReportsReq) {
|
||||
.leftJoin(strikeReason, eq(strike.strikeReasonId, strikeReason.id))
|
||||
.where(
|
||||
and(
|
||||
values.reporter != null ? eq(report.reporterId, reporterIdSubquery!.id) : undefined,
|
||||
values.reported != null ? eq(report.reportedId, reportedIdSubquery!.id) : undefined,
|
||||
values.reporter != null ? eq(reporter.username, values.reporter) : undefined,
|
||||
values.reported != null ? eq(reported.username, values.reported) : undefined,
|
||||
values.includeDrafts == false ? isNotNull(report.createdAt) : undefined
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user