Browse Source

fix msg storage from other subscriber

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

4
api/controllers/chatTribes.ts

@ -161,7 +161,6 @@ async function replayChatHistory(chat, contact) {
...owner.dataValues, ...owner.dataValues,
...m.senderAlias && {alias: m.senderAlias}, ...m.senderAlias && {alias: m.senderAlias},
} }
console.log('sender',sender)
let content = '' let content = ''
try {content = JSON.parse(m.remoteMessageContent)} catch(e) {} try {content = JSON.parse(m.remoteMessageContent)} catch(e) {}
if(!content) return if(!content) return
@ -171,12 +170,9 @@ async function replayChatHistory(chat, contact) {
...m.mediaType && {mediaType: m.mediaType}, ...m.mediaType && {mediaType: m.mediaType},
...m.mediaToken && {mediaToken: m.mediaToken} ...m.mediaToken && {mediaToken: m.mediaToken}
}) })
console.log('msg',msg)
msg = await decryptMessage(msg, chat) msg = await decryptMessage(msg, chat)
const data = await personalizeMessage(msg, contact, true) const data = await personalizeMessage(msg, contact, true)
console.log({data})
const mqttTopic = `${contact.publicKey}/${chat.uuid}` const mqttTopic = `${contact.publicKey}/${chat.uuid}`
return
await network.signAndSend({data}, owner.publicKey, mqttTopic) await network.signAndSend({data}, owner.publicKey, mqttTopic)
}) })
} }

2
api/network/receive.ts

@ -63,7 +63,7 @@ async function doTheAction(data){
const pld = await decryptMessage(data, chat) const pld = await decryptMessage(data, chat)
const me = await models.Contact.findOne({where:{isOwner:true}}) const me = await models.Contact.findOne({where:{isOwner:true}})
payload = await encryptTribeBroadcast(pld, me, true) // true=isTribeOwner payload = await encryptTribeBroadcast(pld, me, true) // true=isTribeOwner
if(ogContent) payload.message.remoteContent = ogContent if(ogContent) payload.message.remoteContent = JSON.stringify({'chat':ogContent}) // this is the key
} }
if(ACTIONS[payload.type]) { if(ACTIONS[payload.type]) {
ACTIONS[payload.type](payload) ACTIONS[payload.type](payload)

4
dist/api/controllers/chatTribes.js

@ -157,7 +157,6 @@ function replayChatHistory(chat, contact) {
if (m.type !== constants.message_types.message) if (m.type !== constants.message_types.message)
return; // only for message for now return; // only for message for now
const sender = Object.assign(Object.assign({}, owner.dataValues), m.senderAlias && { alias: m.senderAlias }); const sender = Object.assign(Object.assign({}, owner.dataValues), m.senderAlias && { alias: m.senderAlias });
console.log('sender', sender);
let content = ''; let content = '';
try { try {
content = JSON.parse(m.remoteMessageContent); content = JSON.parse(m.remoteMessageContent);
@ -166,12 +165,9 @@ function replayChatHistory(chat, contact) {
if (!content) if (!content)
return; return;
let msg = network.newmsg(m.type, chat, sender, Object.assign(Object.assign(Object.assign({ content }, m.mediaKey && { mediaKey: m.mediaKey }), m.mediaType && { mediaType: m.mediaType }), m.mediaToken && { mediaToken: m.mediaToken })); let msg = network.newmsg(m.type, chat, sender, Object.assign(Object.assign(Object.assign({ content }, m.mediaKey && { mediaKey: m.mediaKey }), m.mediaType && { mediaType: m.mediaType }), m.mediaToken && { mediaToken: m.mediaToken }));
console.log('msg', msg);
msg = yield msg_1.decryptMessage(msg, chat); msg = yield msg_1.decryptMessage(msg, chat);
const data = yield msg_1.personalizeMessage(msg, contact, true); const data = yield msg_1.personalizeMessage(msg, contact, true);
console.log({ data });
const mqttTopic = `${contact.publicKey}/${chat.uuid}`; const mqttTopic = `${contact.publicKey}/${chat.uuid}`;
return;
yield network.signAndSend({ data }, owner.publicKey, mqttTopic); yield network.signAndSend({ data }, owner.publicKey, mqttTopic);
})); }));
}); });

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

File diff suppressed because one or more lines are too long

2
dist/api/network/receive.js

@ -81,7 +81,7 @@ function doTheAction(data) {
const me = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const me = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
payload = yield msg_1.encryptTribeBroadcast(pld, me, true); // true=isTribeOwner payload = yield msg_1.encryptTribeBroadcast(pld, me, true); // true=isTribeOwner
if (ogContent) if (ogContent)
payload.message.remoteContent = ogContent; payload.message.remoteContent = JSON.stringify({ 'chat': ogContent }); // this is the key
} }
if (controllers_1.ACTIONS[payload.type]) { if (controllers_1.ACTIONS[payload.type]) {
controllers_1.ACTIONS[payload.type](payload); controllers_1.ACTIONS[payload.type](payload);

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

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