Browse Source

edit tribe params

push-params
Evan Feenstra 4 years ago
parent
commit
abd6135425
  1. 60
      api/controllers/chatTribes.ts
  2. 70
      dist/api/controllers/chatTribes.js
  3. 2
      dist/api/controllers/chatTribes.js.map

60
api/controllers/chatTribes.ts

@ -204,37 +204,41 @@ export async function editTribe(req, res) {
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 (owner.publicKey===chat.ownerPubkey) {
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,
})
const obj:{[k:string]:any} = {}
if(img) obj.img=img
if(name) obj.name=name
if(price_per_message) obj.pricePerMessage=price_per_message
if(price_to_join) obj.priceToJoin = price_to_join
if(escrow_amount) obj.escrowAmount = escrow_amount
if(escrow_millis) obj.escrowMillis = escrow_millis
if(unlisted) obj.unlisted = unlisted
if(req.body.private) obj.private = req.body.private
if(Object.keys(obj).length>0) {
await chat.update(obj)
}
success(res, jsonUtils.chatToJson(chat))
} else {
failure(res, 'failed to update tribe')

70
dist/api/controllers/chatTribes.js

@ -193,37 +193,49 @@ function editTribe(req, res) {
}
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 (owner.publicKey === chat.ownerPubkey) {
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,
});
const obj = {};
if (img)
obj.img = img;
if (name)
obj.name = name;
if (price_per_message)
obj.pricePerMessage = price_per_message;
if (price_to_join)
obj.priceToJoin = price_to_join;
if (escrow_amount)
obj.escrowAmount = escrow_amount;
if (escrow_millis)
obj.escrowMillis = escrow_millis;
if (unlisted)
obj.unlisted = unlisted;
if (req.body.private)
obj.private = req.body.private;
if (Object.keys(obj).length > 0) {
yield chat.update(obj);
}
res_1.success(res, jsonUtils.chatToJson(chat));
}
else {

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

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