Skip to content

Commit

Permalink
fix: fix error when msg.space is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Aug 27, 2023
1 parent de71f4b commit a866a05
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,21 @@ router.get('/api/messages/:hash', async (req, res) => {
});

router.post('/', async (req, res) => {
const msg = req.body.data.message;

if (!req.body.data || !req.body.data.message) {
return res.status(400).json({
error: 'Invalid format request'
});
}

if (!req.body.data.types.Space && !msg.settings && !msg.space) {
return res.status(400).json({
error: 'Missing space'
});
}

try {
const msg = req.body.data.message;
const msgHash = snapshot.utils.getHash(req.body.data);
const address = getAddress(req.body.address);
const env = 'livenet';
Expand Down

0 comments on commit a866a05

Please sign in to comment.