Browse Source

fix local boost msg

dependabot/npm_and_yarn/ini-1.3.7
Evan Feenstra 4 years ago
parent
commit
5de2c8f569
  1. 31
      dist/src/controllers/messages.js
  2. 2
      dist/src/controllers/messages.js.map
  3. 32
      src/controllers/messages.ts

31
dist/src/controllers/messages.js

@ -151,10 +151,23 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
owner_id: owner.id,
recipient_id: contact_id,
});
let realSatsContactId;
// IF BOOST AND TRIBE OWNER NEED TO SEND ACTUAL SATS TO OG POSTER
const isTribe = chat.type === constants_1.default.chat_types.tribe;
const isTribeOwner = isTribe && owner.publicKey === chat.ownerPubkey;
if (isTribeOwner && reply_uuid && boost && amount) {
const ogMsg = yield models_1.models.Message.findOne({ where: {
uuid: reply_uuid,
} });
if (ogMsg && ogMsg.sender) {
realSatsContactId = ogMsg.sender;
}
}
const remoteMessageContent = remote_text_map ? JSON.stringify(remote_text_map) : remote_text;
const uuid = short.generate();
const msg = {
chatId: chat.id,
uuid: short.generate(),
uuid: uuid,
type: msgtype,
sender: owner.id,
amount: amount || 0,
@ -164,6 +177,9 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
status: constants_1.default.statuses.pending,
createdAt: date,
updatedAt: date,
network_type: realSatsContactId ?
constants_1.default.network_types.lightning :
constants_1.default.network_types.mqtt
};
if (reply_uuid)
msg.replyUuid = reply_uuid;
@ -184,17 +200,8 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
type: msgtype,
message: msgToSend,
};
// IF BOOST AND TRIBE OWNER NEED TO SEND ACTUAL SATS TO OG POSTER
const isTribe = chat.type === constants_1.default.chat_types.tribe;
const isTribeOwner = isTribe && owner.publicKey === chat.ownerPubkey;
if (isTribeOwner && reply_uuid && boost && amount) {
const ogMsg = yield models_1.models.Message.findOne({ where: {
uuid: reply_uuid,
} });
if (ogMsg && ogMsg.sender) {
sendMessageParams.realSatsContactId = ogMsg.sender;
}
}
if (realSatsContactId)
sendMessageParams.realSatsContactId = realSatsContactId;
// final send
network.sendMessage(sendMessageParams);
});

2
dist/src/controllers/messages.js.map

File diff suppressed because one or more lines are too long

32
src/controllers/messages.ts

@ -173,10 +173,24 @@ export const sendMessage = async (req, res) => {
recipient_id: contact_id,
})
let realSatsContactId
// IF BOOST AND TRIBE OWNER NEED TO SEND ACTUAL SATS TO OG POSTER
const isTribe = chat.type===constants.chat_types.tribe
const isTribeOwner = isTribe && owner.publicKey===chat.ownerPubkey
if(isTribeOwner && reply_uuid && boost && amount) {
const ogMsg = await models.Message.findOne({where:{
uuid: reply_uuid,
}})
if(ogMsg && ogMsg.sender) {
realSatsContactId = ogMsg.sender
}
}
const remoteMessageContent = remote_text_map?JSON.stringify(remote_text_map) : remote_text
const uuid = short.generate()
const msg:{[k:string]:any}={
chatId: chat.id,
uuid: short.generate(),
uuid: uuid,
type: msgtype,
sender: owner.id,
amount: amount||0,
@ -186,6 +200,9 @@ export const sendMessage = async (req, res) => {
status: constants.statuses.pending,
createdAt: date,
updatedAt: date,
network_type: realSatsContactId ?
constants.network_types.lightning :
constants.network_types.mqtt
}
if(reply_uuid) msg.replyUuid=reply_uuid
// console.log(msg)
@ -207,18 +224,7 @@ export const sendMessage = async (req, res) => {
type: msgtype,
message: msgToSend,
}
// IF BOOST AND TRIBE OWNER NEED TO SEND ACTUAL SATS TO OG POSTER
const isTribe = chat.type===constants.chat_types.tribe
const isTribeOwner = isTribe && owner.publicKey===chat.ownerPubkey
if(isTribeOwner && reply_uuid && boost && amount) {
const ogMsg = await models.Message.findOne({where:{
uuid: reply_uuid,
}})
if(ogMsg && ogMsg.sender) {
sendMessageParams.realSatsContactId = ogMsg.sender
}
}
if(realSatsContactId) sendMessageParams.realSatsContactId = realSatsContactId
// final send
network.sendMessage(sendMessageParams)

Loading…
Cancel
Save