include reporter and reported in report api get
All checks were successful
delpoy / build-and-deploy (push) Successful in 52s
All checks were successful
delpoy / build-and-deploy (push) Successful in 52s
This commit is contained in:
parent
b15b74c9b2
commit
0be3c31b51
@ -13,9 +13,25 @@ export const GET = async ({ url }) => {
|
||||
if (user === null) return new Response(null, { status: 400 });
|
||||
|
||||
const reports = {
|
||||
from_self: await Report.findAll({ where: { reporter_id: user.id } }).then((reports) =>
|
||||
from_self: await Report.findAll({
|
||||
where: { reporter_id: user.id },
|
||||
include: [
|
||||
{ model: User, as: 'reporter' },
|
||||
{ model: User, as: 'reported' }
|
||||
]
|
||||
}).then((reports) =>
|
||||
reports.map((report) => {
|
||||
return {
|
||||
reporter: {
|
||||
username: report.reporter.username,
|
||||
uuid: report.reporter.uuid
|
||||
},
|
||||
reported: report.reported
|
||||
? {
|
||||
username: report.reported.username,
|
||||
uuid: report.reported.uuid
|
||||
}
|
||||
: null,
|
||||
subject: report.subject,
|
||||
draft: report.draft,
|
||||
status: report.status,
|
||||
@ -23,9 +39,23 @@ export const GET = async ({ url }) => {
|
||||
};
|
||||
})
|
||||
),
|
||||
to_self: await Report.findAll({ where: { reported_id: user.id } }).then((reports) =>
|
||||
to_self: await Report.findAll({
|
||||
where: { reported_id: user.id },
|
||||
include: [
|
||||
{ model: User, as: 'reporter' },
|
||||
{ model: User, as: 'reported' }
|
||||
]
|
||||
}).then((reports) =>
|
||||
reports.map((report) => {
|
||||
return {
|
||||
reporter: {
|
||||
username: report.reporter.username,
|
||||
uuid: report.reporter.uuid
|
||||
},
|
||||
reported: {
|
||||
username: report.reported.username,
|
||||
uuid: report.reported.uuid
|
||||
},
|
||||
subject: report.subject,
|
||||
draft: report.draft,
|
||||
status: report.status,
|
||||
|
Loading…
x
Reference in New Issue
Block a user