Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix error when msg.space is empty #140

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ router.get('/api/messages/:hash', async (req, res) => {
});

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

if (!msg) {
return res.status(400).json({
error: 'Invalid format request'
});
}

if (!req.body.data.types.Space && !msg.settings && !msg.space) {
wa0x6e marked this conversation as resolved.
Show resolved Hide resolved
return res.status(400).json({
error: 'Missing space'
});
}

let address;
try {
address = getAddress(req.body.address);
Expand All @@ -82,7 +90,6 @@ router.post('/', async (req, res) => {
}

try {
const msg = req.body.data.message;
const msgHash = snapshot.utils.getHash(req.body.data);
const env = 'livenet';
let network = env === 'livenet' ? '1' : '5';
Expand Down