manal invite & remove member from shoppinglist
This commit is contained in:
@ -382,6 +382,7 @@ async function createInvite(sl_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//User manuell einladen
|
||||||
async function manInvite(sl_id, uid) {
|
async function manInvite(sl_id, uid) {
|
||||||
try {
|
try {
|
||||||
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [uid, sl_id]);
|
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [uid, sl_id]);
|
||||||
@ -392,7 +393,17 @@ async function manInvite(sl_id, uid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//member von shoppinglist entfernen
|
||||||
|
|
||||||
|
async function removeMember(uid, sl_id) {
|
||||||
|
try {
|
||||||
|
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE username = $1 AND sl_id = $2', [uid, sl_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -550,5 +561,5 @@ function probability(cur_item, data) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
|
getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
|
||||||
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup, deleteItem, manInvite, updateUser,
|
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup, deleteItem, manInvite, updateUser,
|
||||||
moveDoneItems, getDonePurchases, getShoppinglistsByLink, searchUsers
|
moveDoneItems, getDonePurchases, getShoppinglistsByLink, searchUsers, removeMember
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,12 @@ function updateUser() {
|
|||||||
function testSearch() {
|
function testSearch() {
|
||||||
console.log("dpne");
|
console.log("dpne");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "DELETE",
|
||||||
url: "/users?search=Lukas",
|
url: "/member",
|
||||||
|
data: {
|
||||||
|
sl_id: "PDADo1iJ",
|
||||||
|
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
||||||
|
},
|
||||||
success(data) {
|
success(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
},
|
},
|
||||||
|
@ -345,22 +345,25 @@ router.post("/invite", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post("/maninvite", async (req, res) => {
|
router.post("/maninvite", async (req, res) => {
|
||||||
|
|
||||||
var token = req.query.idtoken;
|
|
||||||
var uid;
|
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
|
||||||
.then(function(decodedToken) {
|
|
||||||
uid = decodedToken.uid;
|
|
||||||
console.log("UID: ", uid);
|
|
||||||
try {
|
try {
|
||||||
res.status(200).send(postgres.manInvite(req.body.sl_id, uid));
|
res.status(200).send(await postgres.manInvite(req.body.sl_id, req.body.uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(err) {
|
catch(err) {
|
||||||
console.error(error);
|
res.status(400).send(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
router.delete("/member", (req, res) => {
|
||||||
|
try {
|
||||||
|
postgres.removeMember(req.body.uid, req.body.sl_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(err) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
|
||||||
console.error(error)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/invite/:invitelink", async (req, res) => {
|
router.get("/invite/:invitelink", async (req, res) => {
|
||||||
|
Reference in New Issue
Block a user