|
|
@ -179,6 +179,57 @@ function receiveMemberRequest(payload) { |
|
|
|
}); |
|
|
|
} |
|
|
|
exports.receiveMemberRequest = receiveMemberRequest; |
|
|
|
function editTribe(req, res) { |
|
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
|
const { name, price_per_message, price_to_join, escrow_amount, escrow_millis, img, description, tags, unlisted, } = req.body; |
|
|
|
const { id } = req.params; |
|
|
|
if (!id) |
|
|
|
return res_1.failure(res, 'group id is required'); |
|
|
|
const chat = yield models_1.models.Chat.findOne({ where: { id } }); |
|
|
|
if (!chat) { |
|
|
|
return res_1.failure(res, 'cant find chat'); |
|
|
|
} |
|
|
|
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); |
|
|
|
let okToUpdate = true; |
|
|
|
try { |
|
|
|
yield tribes.edit({ |
|
|
|
uuid: chat.uuid, |
|
|
|
name: name, |
|
|
|
host: chat.host, |
|
|
|
price_per_message: price_per_message || 0, |
|
|
|
price_to_join: price_to_join || 0, |
|
|
|
escrow_amount: escrow_amount || 0, |
|
|
|
escrow_millis: escrow_millis || 0, |
|
|
|
description, |
|
|
|
tags, |
|
|
|
img, |
|
|
|
owner_alias: owner.alias, |
|
|
|
unlisted, |
|
|
|
is_private: req.body.private |
|
|
|
}); |
|
|
|
} |
|
|
|
catch (e) { |
|
|
|
okToUpdate = false; |
|
|
|
} |
|
|
|
if (okToUpdate) { |
|
|
|
yield chat.update({ |
|
|
|
photoUrl: img || '', |
|
|
|
name: name, |
|
|
|
pricePerMessage: price_per_message || 0, |
|
|
|
priceToJoin: price_to_join || 0, |
|
|
|
escrowAmount: escrow_amount || 0, |
|
|
|
escrowMillis: escrow_millis || 0, |
|
|
|
unlisted: unlisted || false, |
|
|
|
private: req.body.private || false, |
|
|
|
}); |
|
|
|
res_1.success(res, jsonUtils.chatToJson(chat)); |
|
|
|
} |
|
|
|
else { |
|
|
|
res_1.failure(res, 'failed to update tribe'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
exports.editTribe = editTribe; |
|
|
|
function approveOrRejectMember(req, res) { |
|
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
|
console.log('=> approve or reject tribe member'); |
|
|
|