Browse Source

send self id in msg purchaser field

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
ce66742471
  1. 3
      api/controllers/media.ts
  2. 13
      api/network/receive.ts
  3. 3
      dist/api/controllers/media.js
  4. 2
      dist/api/controllers/media.js.map
  5. 13
      dist/api/network/receive.js
  6. 2
      dist/api/network/receive.js.map

3
api/controllers/media.ts

@ -194,7 +194,8 @@ const purchase = async (req, res) => {
})
const msg={
amount, mediaToken:media_token, id:message.id, uuid:message.uuid,
mediaToken:media_token, id:message.id, uuid:message.uuid,
purchaser: owner.id, // for tribe, knows who sent
}
network.sendMessage({
chat: {...chat.dataValues, contactIds:[contact_id]},

13
api/network/receive.ts

@ -9,7 +9,6 @@ import {sendMessage} from './send'
import {modifyPayloadAndSaveMediaKey,purchaseFromOriginalSender,sendFinalMemeIfFirstPurchaser} from './modify'
// import {modifyPayloadAndSaveMediaKey} from './modify'
import {decryptMessage,encryptTribeBroadcast} from '../utils/msg'
import { Op } from 'sequelize'
const constants = require(path.join(__dirname,'../../config/constants.json'))
const msgtypes = constants.message_types
@ -75,15 +74,9 @@ async function onReceive(payload){
}
}
if(isTribeOwner && payload.type===msgtypes.purchase_accept) {
const mt = payload.message.mediaToken
const host = mt && mt.split('.').length && mt.split('.')[0]
const muid = mt && mt.split('.').length && mt.split('.')[1]
const ogPurchaseMessage = await models.Message.findOne({where:{
mediaToken: {[Op.like]: `${host}.${muid}%`},
type: msgtypes.purchase,
sender: 1,
}})
if(!ogPurchaseMessage) { // for someone else
const purchaserID = payload.message&&payload.message.purchaser
const iAmPurchaser = purchaserID&&purchaserID===1
if(!iAmPurchaser) {
const senderContact = await models.Contact.findOne({where:{publicKey:payload.sender.pub_key}})
sendFinalMemeIfFirstPurchaser(payload, chat, senderContact)
doAction = false // skip this! we dont need it

3
dist/api/controllers/media.js

@ -172,7 +172,8 @@ const purchase = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
updatedAt: date
});
const msg = {
amount, mediaToken: media_token, id: message.id, uuid: message.uuid,
mediaToken: media_token, id: message.id, uuid: message.uuid,
purchaser: owner.id,
};
network.sendMessage({
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [contact_id] }),

2
dist/api/controllers/media.js.map

File diff suppressed because one or more lines are too long

13
dist/api/network/receive.js

@ -20,7 +20,6 @@ const send_1 = require("./send");
const modify_1 = require("./modify");
// import {modifyPayloadAndSaveMediaKey} from './modify'
const msg_1 = require("../utils/msg");
const sequelize_1 = require("sequelize");
const constants = require(path.join(__dirname, '../../config/constants.json'));
const msgtypes = constants.message_types;
exports.typesToForward = [
@ -91,15 +90,9 @@ function onReceive(payload) {
}
}
if (isTribeOwner && payload.type === msgtypes.purchase_accept) {
const mt = payload.message.mediaToken;
const host = mt && mt.split('.').length && mt.split('.')[0];
const muid = mt && mt.split('.').length && mt.split('.')[1];
const ogPurchaseMessage = yield models_1.models.Message.findOne({ where: {
mediaToken: { [sequelize_1.Op.like]: `${host}.${muid}%` },
type: msgtypes.purchase,
sender: 1,
} });
if (!ogPurchaseMessage) { // for someone else
const purchaserID = payload.message && payload.message.purchaser;
const iAmPurchaser = purchaserID && purchaserID === 1;
if (!iAmPurchaser) {
const senderContact = yield models_1.models.Contact.findOne({ where: { publicKey: payload.sender.pub_key } });
modify_1.sendFinalMemeIfFirstPurchaser(payload, chat, senderContact);
doAction = false; // skip this! we dont need it

2
dist/api/network/receive.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save