Browse Source

test remote content store and replay

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
119ca6b737
  1. 3
      api/controllers/messages.ts
  2. 3
      api/helpers.ts
  3. 2
      api/network/receive.ts
  4. 4
      dist/api/controllers/messages.js
  5. 2
      dist/api/controllers/messages.js.map
  6. 3
      dist/api/helpers.js
  7. 2
      dist/api/helpers.js.map
  8. 3
      dist/api/network/receive.js
  9. 2
      dist/api/network/receive.js.map

3
api/controllers/messages.ts

@ -156,7 +156,7 @@ const receiveMessage = async (payload) => {
date.setMilliseconds(0)
const total_spent = 1
const {owner, sender, chat, content, msg_id, chat_type, sender_alias} = await helpers.parseReceiveParams(payload)
const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
@ -175,6 +175,7 @@ const receiveMessage = async (payload) => {
}
if(chat_type===constants.chat_types.tribe) {
msg.senderAlias = sender_alias
if(remote_content) msg.remoteMessageContent=remote_content
}
const message = await models.Message.create(msg)

3
api/helpers.ts

@ -143,6 +143,7 @@ async function parseReceiveParams(payload) {
const chat_host = dat.chat.host
const amount = dat.message.amount
const content = dat.message.content
const remote_content = dat.message.remoteContent
const mediaToken = dat.message.mediaToken
const msg_id = dat.message.id||0
const mediaKey = dat.message.mediaKey
@ -169,7 +170,7 @@ async function parseReceiveParams(payload) {
}
chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
}
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key }
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content }
}
export {

2
api/network/receive.ts

@ -57,11 +57,13 @@ async function onReceive(payload){
async function doTheAction(data){
let payload = data
if(payload.isTribeOwner) {
const ogContent = data.message && data.message.content
// decrypt and re-encrypt with self pubkey
const chat = await models.Chat.findOne({where:{uuid:payload.chat.uuid}})
const pld = await decryptMessage(data, chat)
const me = await models.Contact.findOne({where:{isOwner:true}})
payload = await encryptTribeBroadcast(pld, me, true) // true=isTribeOwner
if(ogContent) payload.message.remoteContent = ogContent
}
if(ACTIONS[payload.type]) {
ACTIONS[payload.type](payload)

4
dist/api/controllers/messages.js

@ -139,7 +139,7 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
var date = new Date();
date.setMilliseconds(0);
const total_spent = 1;
const { owner, sender, chat, content, msg_id, chat_type, sender_alias } = yield helpers.parseReceiveParams(payload);
const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
@ -157,6 +157,8 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
};
if (chat_type === constants.chat_types.tribe) {
msg.senderAlias = sender_alias;
if (remote_content)
msg.remoteMessageContent = remote_content;
}
const message = yield models_1.models.Message.create(msg);
console.log('saved message', message.dataValues);

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

File diff suppressed because one or more lines are too long

3
dist/api/helpers.js

@ -159,6 +159,7 @@ function parseReceiveParams(payload) {
const chat_host = dat.chat.host;
const amount = dat.message.amount;
const content = dat.message.content;
const remote_content = dat.message.remoteContent;
const mediaToken = dat.message.mediaToken;
const msg_id = dat.message.id || 0;
const mediaKey = dat.message.mediaKey;
@ -183,7 +184,7 @@ function parseReceiveParams(payload) {
}
chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
}
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key };
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content };
});
}
exports.parseReceiveParams = parseReceiveParams;

2
dist/api/helpers.js.map

File diff suppressed because one or more lines are too long

3
dist/api/network/receive.js

@ -74,11 +74,14 @@ function doTheAction(data) {
return __awaiter(this, void 0, void 0, function* () {
let payload = data;
if (payload.isTribeOwner) {
const ogContent = data.message && data.message.content;
// decrypt and re-encrypt with self pubkey
const chat = yield models_1.models.Chat.findOne({ where: { uuid: payload.chat.uuid } });
const pld = yield msg_1.decryptMessage(data, chat);
const me = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
payload = yield msg_1.encryptTribeBroadcast(pld, me, true); // true=isTribeOwner
if (ogContent)
payload.message.remoteContent = ogContent;
}
if (ACTIONS[payload.type]) {
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