mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-18 10:50:18 -04:00
add join_pool API method
This commit is contained in:
parent
fa4c931742
commit
0d53ed2352
16
src/api.ts
16
src/api.ts
|
@ -6,6 +6,7 @@ import {
|
|||
getPoolsWithUser,
|
||||
getUserByID,
|
||||
} from './data';
|
||||
import { PoolModel } from './models';
|
||||
|
||||
export const router = Router();
|
||||
|
||||
|
@ -114,6 +115,21 @@ router.get('/group', (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
router.post('/join_pool', async (req, res) => {
|
||||
if (!req.session.accountID) {
|
||||
return res.json({ status: 'error', error: 'need_login' });
|
||||
} else {
|
||||
let poolID = req.body.id;
|
||||
let userID = req.session.accountID;
|
||||
|
||||
await PoolModel.findByIdAndUpdate(poolID, {
|
||||
$addToSet: { participant_ids: userID },
|
||||
}).exec();
|
||||
|
||||
res.json({ status: 'success' });
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/group', (req, res) => {
|
||||
// if (req.body.groupID in groups) {
|
||||
// res.json({ status: 'error', error: 'already_exists' });
|
||||
|
|
Loading…
Reference in New Issue
Block a user