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