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:
@ -13,9 +13,25 @@ export const GET = async ({ url }) => {
|
|||||||
if (user === null) return new Response(null, { status: 400 });
|
if (user === null) return new Response(null, { status: 400 });
|
||||||
|
|
||||||
const reports = {
|
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) => {
|
reports.map((report) => {
|
||||||
return {
|
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,
|
subject: report.subject,
|
||||||
draft: report.draft,
|
draft: report.draft,
|
||||||
status: report.status,
|
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) => {
|
reports.map((report) => {
|
||||||
return {
|
return {
|
||||||
|
reporter: {
|
||||||
|
username: report.reporter.username,
|
||||||
|
uuid: report.reporter.uuid
|
||||||
|
},
|
||||||
|
reported: {
|
||||||
|
username: report.reported.username,
|
||||||
|
uuid: report.reported.uuid
|
||||||
|
},
|
||||||
subject: report.subject,
|
subject: report.subject,
|
||||||
draft: report.draft,
|
draft: report.draft,
|
||||||
status: report.status,
|
status: report.status,
|
||||||
|
Reference in New Issue
Block a user