|
@ -23,7 +23,11 @@ const MIN_SATS = 3; |
|
|
function sendMessage(params) { |
|
|
function sendMessage(params) { |
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params; |
|
|
const { type, chat, message, sender, amount, success, failure, skipPubKey } = params; |
|
|
let msg = newmsg(type, chat, sender, message); |
|
|
if (!chat || !sender) |
|
|
|
|
|
return; |
|
|
|
|
|
const isTribe = chat.type === constants.chat_types.tribe; |
|
|
|
|
|
let isTribeOwner = isTribe && sender.publicKey === chat.ownerPubkey; |
|
|
|
|
|
let msg = newmsg(type, chat, sender, message, isTribeOwner); |
|
|
// console.log("=> MSG TO SEND",msg)
|
|
|
// console.log("=> MSG TO SEND",msg)
|
|
|
// console.log(type,message)
|
|
|
// console.log(type,message)
|
|
|
if (!(sender && sender.publicKey)) { |
|
|
if (!(sender && sender.publicKey)) { |
|
@ -39,12 +43,8 @@ function sendMessage(params) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
let networkType = undefined; |
|
|
let networkType = undefined; |
|
|
const isTribe = chat.type === constants.chat_types.tribe; |
|
|
|
|
|
let isTribeOwner = false; |
|
|
|
|
|
const chatUUID = chat.uuid; |
|
|
const chatUUID = chat.uuid; |
|
|
if (isTribe) { |
|
|
if (isTribe) { |
|
|
const tribeOwnerPubKey = chat.ownerPubkey; |
|
|
|
|
|
isTribeOwner = sender.publicKey === tribeOwnerPubKey; |
|
|
|
|
|
if (type === constants.message_types.confirmation) { |
|
|
if (type === constants.message_types.confirmation) { |
|
|
// if u are owner, go ahead!
|
|
|
// if u are owner, go ahead!
|
|
|
if (!isTribeOwner) |
|
|
if (!isTribeOwner) |
|
@ -64,7 +64,7 @@ function sendMessage(params) { |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
// if tribe, send to owner only
|
|
|
// if tribe, send to owner only
|
|
|
const tribeOwner = yield models_1.models.Contact.findOne({ where: { publicKey: tribeOwnerPubKey } }); |
|
|
const tribeOwner = yield models_1.models.Contact.findOne({ where: { publicKey: chat.ownerPubkey } }); |
|
|
contactIds = tribeOwner ? [tribeOwner.id] : []; |
|
|
contactIds = tribeOwner ? [tribeOwner.id] : []; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -160,7 +160,7 @@ function checkIfAutoConfirm(data) { |
|
|
confirmations_1.tribeOwnerAutoConfirmation(data.message.id, data.chat.uuid); |
|
|
confirmations_1.tribeOwnerAutoConfirmation(data.message.id, data.chat.uuid); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function newmsg(type, chat, sender, message) { |
|
|
function newmsg(type, chat, sender, message, isTribeOwner) { |
|
|
const includeGroupKey = type === constants.message_types.group_create || type === constants.message_types.group_invite; |
|
|
const includeGroupKey = type === constants.message_types.group_create || type === constants.message_types.group_invite; |
|
|
const includeAlias = sender && sender.alias && chat.type === constants.chat_types.tribe; |
|
|
const includeAlias = sender && sender.alias && chat.type === constants.chat_types.tribe; |
|
|
// const includePhotoUrl = sender && sender.photoUrl && !sender.privatePhoto
|
|
|
// const includePhotoUrl = sender && sender.photoUrl && !sender.privatePhoto
|
|
@ -171,7 +171,7 @@ function newmsg(type, chat, sender, message) { |
|
|
sender: { |
|
|
sender: { |
|
|
pub_key: sender.publicKey, |
|
|
pub_key: sender.publicKey, |
|
|
alias: includeAlias ? sender.alias : '', |
|
|
alias: includeAlias ? sender.alias : '', |
|
|
role: sender.role || constants.chat_roles.reader, |
|
|
role: isTribeOwner ? constants.chat_roles.owner : constants.chat_roles.reader, |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|