Browse Source

fix

push-params
Evan Feenstra 5 years ago
parent
commit
a498071bf9
  1. 61
      api/controllers/chatTribes.ts
  2. 2
      api/controllers/index.ts
  3. 51
      dist/api/controllers/chatTribes.js
  4. 2
      dist/api/controllers/chatTribes.js.map
  5. 2
      dist/api/controllers/index.js
  6. 2
      dist/api/controllers/index.js.map

61
api/controllers/chatTribes.ts

@ -178,6 +178,67 @@ export async function receiveMemberRequest(payload) {
})
}
export async function editTribe(req, res) {
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 failure(res, 'group id is required')
const chat = await models.Chat.findOne({where:{id}})
if(!chat) {
return failure(res, 'cant find chat')
}
const owner = await models.Contact.findOne({ where: { isOwner: true } })
let okToUpdate = true
try{
await 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) {
await 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,
})
success(res, jsonUtils.chatToJson(chat))
} else {
failure(res, 'failed to update tribe')
}
}
export async function approveOrRejectMember(req,res) {
console.log('=> approve or reject tribe member')
const chatId = parseInt(req.params['chatId'])

2
api/controllers/index.ts

@ -42,7 +42,7 @@ export async function set(app) {
app.put('/kick/:chat_id/:contact_id', chats.kickChatMember)
app.post('/tribe', chatTribes.joinTribe)
app.put('/member/:chatId/:contactId/:status', chatTribes.approveOrRejectMember)
// app.put('/group/:id', chatTribes.editTribe)
app.put('/group/:id', chatTribes.editTribe)
app.post('/upload', uploads.avatarUpload.single('file'), uploads.uploadFile)

51
dist/api/controllers/chatTribes.js

@ -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');

2
dist/api/controllers/chatTribes.js.map

File diff suppressed because one or more lines are too long

2
dist/api/controllers/index.js

@ -49,7 +49,7 @@ function set(app) {
app.put('/kick/:chat_id/:contact_id', chats.kickChatMember);
app.post('/tribe', chatTribes.joinTribe);
app.put('/member/:chatId/:contactId/:status', chatTribes.approveOrRejectMember);
// app.put('/group/:id', chatTribes.editTribe)
app.put('/group/:id', chatTribes.editTribe);
app.post('/upload', uploads.avatarUpload.single('file'), uploads.uploadFile);
app.post('/invites', invites.createInvite);
app.post('/invites/:invite_string/pay', invites.payInvite);

2
dist/api/controllers/index.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save