Browse Source

use like clause to get the original purchase message sender id

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
9c23c6404f
  1. 13
      api/network/modify.ts
  2. 7
      dist/api/network/modify.js
  3. 2
      dist/api/network/modify.js.map

13
api/network/modify.ts

@ -41,7 +41,7 @@ export async function purchaseFromOriginalSender(payload, chat, purchaser){
const owner = await models.Contact.findOne({where: {isOwner:true}})
if(mediaKey) { // ALREADY BEEN PURHCASED! simply send
console.log("MEDIA KEY EXISTS ALREADY",mediaKey)
console.log("MEDIA KEY EXISTS ALREADY",mediaKey)
// send back the new mediaToken and key
const mediaTerms: {[k:string]:any} = {
muid, ttl:31536000, host:'',
@ -59,7 +59,7 @@ export async function purchaseFromOriginalSender(payload, chat, purchaser){
failure: ()=>{}
})
} else {
console.log("NO MEDIA KEY EXISTS YET")
console.log("NO MEDIA KEY EXISTS YET")
const ogmsg = await models.Message.findOne({where:{chatId:chat.id,mediaToken:mt}})
// purchase it from creator (send "purchase")
const msg={amount, mediaToken:mt}
@ -107,6 +107,13 @@ export async function sendFinalMemeIfFirstPurchaser(payload, chat, sender){
console.log("DOWNLOAD AND REIP:OAD",mt)
const termsAndKey = await downloadAndUploadAndSaveReturningTermsAndKey(payload,chat,sender)
const host = mt.split('.')[0]
const ogPurchaseMessage = await models.Message.findOne({where:{
mediaToken: {$like: `${host}.${muid}%`}
}})
console.log('ogPurchaseMessage',ogPurchaseMessage.dataValues)
// send it to the purchaser
const owner = await models.Contact.findOne({where: {isOwner:true}})
console.log("SEND firST PURHCASE ACCEPT MSG!")
@ -117,7 +124,7 @@ export async function sendFinalMemeIfFirstPurchaser(payload, chat, sender){
},
chat:{
...chat.dataValues,
contactIds:[sender.id],
contactIds:[ogPurchaseMessage.sender],
},
type:msgtypes.purchase_accept,
message:{

7
dist/api/network/modify.js

@ -115,12 +115,17 @@ function sendFinalMemeIfFirstPurchaser(payload, chat, sender) {
return; // no need, its already been sent
console.log("DOWNLOAD AND REIP:OAD", mt);
const termsAndKey = yield downloadAndUploadAndSaveReturningTermsAndKey(payload, chat, sender);
const host = mt.split('.')[0];
const ogPurchaseMessage = yield models_1.models.Message.findOne({ where: {
mediaToken: { $like: `${host}.${muid}%` }
} });
console.log('ogPurchaseMessage', ogPurchaseMessage.dataValues);
// send it to the purchaser
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
console.log("SEND firST PURHCASE ACCEPT MSG!");
send_1.sendMessage({
sender: Object.assign(Object.assign({}, owner.dataValues), sender && sender.alias && { alias: sender.alias }),
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] }),
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [ogPurchaseMessage.sender] }),
type: msgtypes.purchase_accept,
message: Object.assign(Object.assign({}, termsAndKey), { mediaType: typ }),
success: () => { },

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

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