Browse Source

Merge pull request #112 from stakwork/fixboost2

Fixboost2
dependabot/npm_and_yarn/ini-1.3.7 v1.1.1
Evan Feenstra 4 years ago
committed by GitHub
parent
commit
c545d76337
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dist/src/controllers/messages.js
  2. 2
      dist/src/controllers/messages.js.map
  3. 11
      src/controllers/messages.ts

10
dist/src/controllers/messages.js

@ -154,6 +154,7 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
let realSatsContactId;
// IF BOOST 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 (reply_uuid && boost && amount) {
const ogMsg = yield models_1.models.Message.findOne({ where: {
uuid: reply_uuid,
@ -193,7 +194,8 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
const msgToSend = {
id: message.id,
uuid: message.uuid,
content: remote_text_map || remote_text || text
content: remote_text_map || remote_text || text,
amount: amtToStore,
};
if (reply_uuid)
msgToSend.replyUuid = reply_uuid;
@ -206,6 +208,10 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
};
if (realSatsContactId)
sendMessageParams.realSatsContactId = realSatsContactId;
// tribe owner deducts the "price per message + escrow amount"
if (realSatsContactId && isTribeOwner && amtToStore) {
sendMessageParams.amount = amtToStore;
}
// final send
network.sendMessage(sendMessageParams);
});
@ -252,7 +258,7 @@ exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function
});
exports.receiveBoost = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const { owner, sender, chat, content, remote_content, chat_type, sender_alias, msg_uuid, date_string, reply_uuid, amount, network_type } = yield helpers.parseReceiveParams(payload);
console.log('received boost ' + amount + ' sats on network:', network_type);
console.log('=> received boost ' + amount + ' sats on network:', network_type);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}

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

File diff suppressed because one or more lines are too long

11
src/controllers/messages.ts

@ -177,6 +177,7 @@ export const sendMessage = async (req, res) => {
let realSatsContactId
// IF BOOST NEED TO SEND ACTUAL SATS TO OG POSTER
const isTribe = chat.type===constants.chat_types.tribe
const isTribeOwner = isTribe && owner.publicKey===chat.ownerPubkey
if(reply_uuid && boost && amount) {
const ogMsg = await models.Message.findOne({where:{
uuid: reply_uuid,
@ -219,7 +220,8 @@ export const sendMessage = async (req, res) => {
const msgToSend:{[k:string]:any} = {
id: message.id,
uuid: message.uuid,
content: remote_text_map || remote_text || text
content: remote_text_map || remote_text || text,
amount: amtToStore,
}
if(reply_uuid) msgToSend.replyUuid=reply_uuid
@ -231,7 +233,10 @@ export const sendMessage = async (req, res) => {
message: msgToSend,
}
if(realSatsContactId) sendMessageParams.realSatsContactId = realSatsContactId
// tribe owner deducts the "price per message + escrow amount"
if(realSatsContactId && isTribeOwner && amtToStore) {
sendMessageParams.amount = amtToStore
}
// final send
network.sendMessage(sendMessageParams)
}
@ -283,7 +288,7 @@ export const receiveMessage = async (payload) => {
export const receiveBoost = async (payload) => {
const {owner, sender, chat, content, remote_content, chat_type, sender_alias, msg_uuid, date_string, reply_uuid, amount, network_type} = await helpers.parseReceiveParams(payload)
console.log('received boost ' +amount+ ' sats on network:', network_type)
console.log('=> received boost ' +amount+ ' sats on network:', network_type)
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}

Loading…
Cancel
Save