Browse Source

ogAttachmentMessage for admin attached

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

2
api/controllers/media.ts

@ -108,6 +108,8 @@ const sendAttachmentMessage = async (req, res) => {
updatedAt: date
})
console.log('saved attachment msg from me',message.id)
saveMediaKeys(muid, media_key_map, chat.id, message.id, mediaType)
const mediaTerms: {[k:string]:any} = {

10
api/network/receive.ts

@ -9,6 +9,7 @@ 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
@ -64,10 +65,13 @@ async function onReceive(payload){
}
if(isTribeOwner && payload.type===msgtypes.purchase) {
const mt = payload.message.mediaToken
const myMediaMessage = await models.Message.findOne({ where:{
mediaToken: mt, sender: 1, type:msgtypes.attachment
const host = mt && mt.split('.').length && mt.split('.')[0]
const muid = mt && mt.split('.').length && mt.split('.')[1]
const myAttachmentMessage = await models.Message.findOne({where:{
mediaToken: {[Op.like]: `${host}.${muid}%`},
type:msgtypes.attachment, sender:1,
}})
if(!myMediaMessage) { // someone else's attachment
if(!myAttachmentMessage) { // someone else's attachment
const senderContact = await models.Contact.findOne({where:{publicKey:payload.sender.pub_key}})
purchaseFromOriginalSender(payload, chat, senderContact)
doAction = false

1
dist/api/controllers/media.js

@ -96,6 +96,7 @@ const sendAttachmentMessage = (req, res) => __awaiter(void 0, void 0, void 0, fu
createdAt: date,
updatedAt: date
});
console.log('saved attachment msg from me', message.id);
saveMediaKeys(muid, media_key_map, chat.id, message.id, mediaType);
const mediaTerms = {
muid, ttl: TTL,

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

File diff suppressed because one or more lines are too long

10
dist/api/network/receive.js

@ -20,6 +20,7 @@ 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 = [
@ -80,10 +81,13 @@ function onReceive(payload) {
}
if (isTribeOwner && payload.type === msgtypes.purchase) {
const mt = payload.message.mediaToken;
const myMediaMessage = yield models_1.models.Message.findOne({ where: {
mediaToken: mt, sender: 1, type: msgtypes.attachment
const host = mt && mt.split('.').length && mt.split('.')[0];
const muid = mt && mt.split('.').length && mt.split('.')[1];
const myAttachmentMessage = yield models_1.models.Message.findOne({ where: {
mediaToken: { [sequelize_1.Op.like]: `${host}.${muid}%` },
type: msgtypes.attachment, sender: 1,
} });
if (!myMediaMessage) { // someone else's attachment
if (!myAttachmentMessage) { // someone else's attachment
const senderContact = yield models_1.models.Contact.findOne({ where: { publicKey: payload.sender.pub_key } });
modify_1.purchaseFromOriginalSender(payload, chat, senderContact);
doAction = false;

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

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