Skip to content

Commit

Permalink
Update inbox.js
Browse files Browse the repository at this point in the history
  • Loading branch information
privt00 committed Apr 15, 2024
1 parent 3d1af7e commit ab2702a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions api/user/inbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ const express = require("express");
module.exports.load = async function (app, db) {
app.get("/api/inbox", async (req, res) => {
try {
if (!req.session.pterodactyl || !req.session.pterodactyl.username) {
if (!req.session.pterodactyl.username) {
return res.status(401).json({ error: 'Unauthorized' });
}

const userId = req.session.pterodactyl.username;
const allUserId = '@a';

const alluserId = '@a';
const inboxData = JSON.parse(fs.readFileSync("./inbox.json", "utf8"));
const userMessages = inboxData.messages.filter(message => message.toUserId === userId);
const allUserMessages = inboxData.messages.filter(message => message.toUserId === allUserId);

res.json({ userMessages, allUserMessages });
const userMessages1 = inboxData.messages.filter(message => message.toUserId === alluserId);
res.json({ messages: userMessages,messages: userMessages1 });
} catch (error) {
console.error('Error loading inbox data:', error);
res.status(500).json({ error: 'Internal Server Error' });
Expand Down

0 comments on commit ab2702a

Please sign in to comment.