|
|
@ -43,7 +43,7 @@ exports.typesToReplay = [ |
|
|
|
]; |
|
|
|
function onReceive(payload) { |
|
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
|
// console.log("=> ON RECEIVE",payload)
|
|
|
|
console.log("==> ON RECEIVE", payload); |
|
|
|
// if tribe, owner must forward to MQTT
|
|
|
|
let doAction = true; |
|
|
|
const toAddIn = {}; |
|
|
@ -115,6 +115,7 @@ function onReceive(payload) { |
|
|
|
console.log('=> insufficient payment for this action'); |
|
|
|
} |
|
|
|
if (isTribeOwner && payload.type === msgtypes.purchase) { |
|
|
|
console.log('==> is purchase, i am trbie owner'); |
|
|
|
const mt = payload.message.mediaToken; |
|
|
|
const host = mt && mt.split('.').length && mt.split('.')[0]; |
|
|
|
const muid = mt && mt.split('.').length && mt.split('.')[1]; |
|
|
@ -123,6 +124,7 @@ function onReceive(payload) { |
|
|
|
type: msgtypes.attachment, sender: 1, |
|
|
|
} }); |
|
|
|
if (!myAttachmentMessage) { // someone else's attachment
|
|
|
|
console.log("==> someone else's attachment, purchase it"); |
|
|
|
const senderContact = yield models_1.models.Contact.findOne({ where: { publicKey: payload.sender.pub_key } }); |
|
|
|
modify_1.purchaseFromOriginalSender(payload, chat, senderContact); |
|
|
|
doAction = false; |
|
|
@ -209,7 +211,6 @@ function initTribesSubscriptions() { |
|
|
|
tribes.connect((topic, message) => __awaiter(this, void 0, void 0, function* () { |
|
|
|
try { |
|
|
|
const msg = message.toString(); |
|
|
|
// console.log("=====> msg received! TOPIC", topic, "MESSAGE", msg)
|
|
|
|
// check topic is signed by sender?
|
|
|
|
const payload = yield parseAndVerifyPayload(msg); |
|
|
|
onReceive(payload); |
|
|
|