Browse Source

cleanup

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
167279166a
  1. 2
      api/network/receive.ts
  2. 7
      api/utils/msg.ts
  3. 2
      dist/api/network/receive.js
  4. 2
      dist/api/network/receive.js.map
  5. 7
      dist/api/utils/msg.js
  6. 2
      dist/api/utils/msg.js.map

2
api/network/receive.ts

@ -15,7 +15,7 @@ const typesToForward=[
] ]
async function onReceive(payload){ async function onReceive(payload){
// if tribe, owner must forward to MQTT // if tribe, owner must forward to MQTT
console.log("RECEIVED PAYLOAD",payload) // console.log("RECEIVED PAYLOAD",payload)
const isTribe = payload.chat && payload.chat.type===constants.chat_types.tribe const isTribe = payload.chat && payload.chat.type===constants.chat_types.tribe
if(isTribe && typesToForward.includes(payload.type)){ if(isTribe && typesToForward.includes(payload.type)){
const tribeOwnerPubKey = await tribes.verifySignedTimestamp(payload.chat.uuid) const tribeOwnerPubKey = await tribes.verifySignedTimestamp(payload.chat.uuid)

7
api/utils/msg.ts

@ -6,12 +6,8 @@ const constants = require(path.join(__dirname,'../../config/constants.json'))
function addInRemoteText(full:{[k:string]:any}, contactId, isTribe:boolean){ function addInRemoteText(full:{[k:string]:any}, contactId, isTribe:boolean){
const m = full && full.message const m = full && full.message
console.log('m && m.content',m && m.content)
console.log('typeof m.content',typeof m.content)
if (!(m && m.content)) return full if (!(m && m.content)) return full
if (!(typeof m.content==='object')) return full if (!(typeof m.content==='object')) return full
console.log('contactId',contactId)
console.log('isTribe',isTribe)
if(isTribe) { if(isTribe) {
// if just one, send it (for tribe remote_text_map... is there a better way?) // if just one, send it (for tribe remote_text_map... is there a better way?)
if(Object.values(m.content).length===1) { if(Object.values(m.content).length===1) {
@ -134,19 +130,16 @@ async function personalizeMessage(m,contact,isTribeOwner:boolean){
const destkey = contact.publicKey const destkey = contact.publicKey
const cloned = JSON.parse(JSON.stringify(m)) const cloned = JSON.parse(JSON.stringify(m))
console.log('cloned',cloned)
const chat = cloned && cloned.chat const chat = cloned && cloned.chat
const isTribe = chat.type&&chat.type===constants.chat_types.tribe const isTribe = chat.type&&chat.type===constants.chat_types.tribe
const msgWithRemoteTxt = addInRemoteText(cloned, contactId, isTribe) const msgWithRemoteTxt = addInRemoteText(cloned, contactId, isTribe)
console.log('msgWithRemoteTxt',msgWithRemoteTxt)
const cleanMsg = removeRecipientFromChatMembers(msgWithRemoteTxt, destkey) const cleanMsg = removeRecipientFromChatMembers(msgWithRemoteTxt, destkey)
const cleanerMsg = removeAllNonAdminMembersIfTribe(cleanMsg, destkey) const cleanerMsg = removeAllNonAdminMembersIfTribe(cleanMsg, destkey)
const msgWithMediaKey = addInMediaKey(cleanerMsg, contactId) const msgWithMediaKey = addInMediaKey(cleanerMsg, contactId)
const msgWithMediaToken = await finishTermsAndReceipt(msgWithMediaKey, destkey) const msgWithMediaToken = await finishTermsAndReceipt(msgWithMediaKey, destkey)
const encMsg = await encryptTribeBroadcast(msgWithMediaToken, contact, isTribe, isTribeOwner) const encMsg = await encryptTribeBroadcast(msgWithMediaToken, contact, isTribe, isTribeOwner)
console.log('encMsg',encMsg)
return encMsg return encMsg
} }

2
dist/api/network/receive.js

@ -25,7 +25,7 @@ const typesToForward = [
function onReceive(payload) { function onReceive(payload) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// if tribe, owner must forward to MQTT // if tribe, owner must forward to MQTT
console.log("RECEIVED PAYLOAD", payload); // console.log("RECEIVED PAYLOAD",payload)
const isTribe = payload.chat && payload.chat.type === constants.chat_types.tribe; const isTribe = payload.chat && payload.chat.type === constants.chat_types.tribe;
if (isTribe && typesToForward.includes(payload.type)) { if (isTribe && typesToForward.includes(payload.type)) {
const tribeOwnerPubKey = yield tribes.verifySignedTimestamp(payload.chat.uuid); const tribeOwnerPubKey = yield tribes.verifySignedTimestamp(payload.chat.uuid);

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

File diff suppressed because one or more lines are too long

7
dist/api/utils/msg.js

@ -15,14 +15,10 @@ const rsa = require("../crypto/rsa");
const constants = require(path.join(__dirname, '../../config/constants.json')); const constants = require(path.join(__dirname, '../../config/constants.json'));
function addInRemoteText(full, contactId, isTribe) { function addInRemoteText(full, contactId, isTribe) {
const m = full && full.message; const m = full && full.message;
console.log('m && m.content', m && m.content);
console.log('typeof m.content', typeof m.content);
if (!(m && m.content)) if (!(m && m.content))
return full; return full;
if (!(typeof m.content === 'object')) if (!(typeof m.content === 'object'))
return full; return full;
console.log('contactId', contactId);
console.log('isTribe', isTribe);
if (isTribe) { if (isTribe) {
// if just one, send it (for tribe remote_text_map... is there a better way?) // if just one, send it (for tribe remote_text_map... is there a better way?)
if (Object.values(m.content).length === 1) { if (Object.values(m.content).length === 1) {
@ -149,17 +145,14 @@ function personalizeMessage(m, contact, isTribeOwner) {
const contactId = contact.id; const contactId = contact.id;
const destkey = contact.publicKey; const destkey = contact.publicKey;
const cloned = JSON.parse(JSON.stringify(m)); const cloned = JSON.parse(JSON.stringify(m));
console.log('cloned', cloned);
const chat = cloned && cloned.chat; const chat = cloned && cloned.chat;
const isTribe = chat.type && chat.type === constants.chat_types.tribe; const isTribe = chat.type && chat.type === constants.chat_types.tribe;
const msgWithRemoteTxt = addInRemoteText(cloned, contactId, isTribe); const msgWithRemoteTxt = addInRemoteText(cloned, contactId, isTribe);
console.log('msgWithRemoteTxt', msgWithRemoteTxt);
const cleanMsg = removeRecipientFromChatMembers(msgWithRemoteTxt, destkey); const cleanMsg = removeRecipientFromChatMembers(msgWithRemoteTxt, destkey);
const cleanerMsg = removeAllNonAdminMembersIfTribe(cleanMsg, destkey); const cleanerMsg = removeAllNonAdminMembersIfTribe(cleanMsg, destkey);
const msgWithMediaKey = addInMediaKey(cleanerMsg, contactId); const msgWithMediaKey = addInMediaKey(cleanerMsg, contactId);
const msgWithMediaToken = yield finishTermsAndReceipt(msgWithMediaKey, destkey); const msgWithMediaToken = yield finishTermsAndReceipt(msgWithMediaKey, destkey);
const encMsg = yield encryptTribeBroadcast(msgWithMediaToken, contact, isTribe, isTribeOwner); const encMsg = yield encryptTribeBroadcast(msgWithMediaToken, contact, isTribe, isTribeOwner);
console.log('encMsg', encMsg);
return encMsg; return encMsg;
}); });
} }

2
dist/api/utils/msg.js.map

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