Browse Source

test

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
c0f45fc241
  1. 35
      api/network/modify.ts
  2. 30
      dist/api/network/modify.js
  3. 2
      dist/api/network/modify.js.map

35
api/network/modify.ts

@ -6,7 +6,7 @@ import * as rsa from '../crypto/rsa'
import * as crypto from 'crypto'
import * as meme from '../utils/meme'
import * as FormData from 'form-data'
import { models } from '../models'
// import { models } from '../models'
const constants = require(path.join(__dirname,'../../config/constants.json'))
const msgtypes = constants.message_types
@ -66,28 +66,31 @@ export async function modifyPayloadAndSaveMediaKey(payload, chat, sender) {
skipSigning: amt ? true : false // only sign if its free
}
const encKey = rsa.encrypt(chat.groupKey, newKey)
const keyToEncrypt = newKey.slice()
const encKey = rsa.encrypt(chat.groupKey, keyToEncrypt)
const keyToSave = encKey.slice()
var date = new Date();
date.setMilliseconds(0)
console.log('[modify] save media key!',{
muid:json.muid,
chatId:chat.id,
key:encKey,
messageId: (payload.message&&payload.message.id)||0,
receiver: 0,
sender: sender.id, // the og sender
createdAt: date,
})
await models.MediaKey.create({
muid:json.muid,
chatId:chat.id,
key:encKey,
key: keyToSave,
messageId: (payload.message&&payload.message.id)||0,
receiver: 0,
sender: sender.id, // the og sender
createdAt: date,
})
// await sleep(1)
// await models.MediaKey.create({
// muid:json.muid,
// chatId:chat.id,
// key:encKey,
// messageId: (payload.message&&payload.message.id)||0,
// receiver: 0,
// sender: sender.id, // the og sender
// createdAt: date,
// })
return fillmsg(payload, {mediaTerms,mediaKey:encKey}) // key is re-encrypted later
} catch(e) {
@ -107,4 +110,8 @@ function fillmsg(full, props){
...props,
}
}
}
}
// async function sleep(ms) {
// return new Promise(resolve => setTimeout(resolve, ms))
// }

30
dist/api/network/modify.js

@ -17,7 +17,7 @@ const rsa = require("../crypto/rsa");
const crypto = require("crypto");
const meme = require("../utils/meme");
const FormData = require("form-data");
const models_1 = require("../models");
// import { models } from '../models'
const constants = require(path.join(__dirname, '../../config/constants.json'));
const msgtypes = constants.message_types;
function modifyPayloadAndSaveMediaKey(payload, chat, sender) {
@ -64,27 +64,30 @@ function modifyPayloadAndSaveMediaKey(payload, chat, sender) {
meta: Object.assign({}, amt && { amt }),
skipSigning: amt ? true : false // only sign if its free
};
const encKey = rsa.encrypt(chat.groupKey, newKey);
const keyToEncrypt = newKey.slice();
const encKey = rsa.encrypt(chat.groupKey, keyToEncrypt);
const keyToSave = encKey.slice();
var date = new Date();
date.setMilliseconds(0);
console.log('[modify] save media key!', {
muid: json.muid,
chatId: chat.id,
key: encKey,
messageId: (payload.message && payload.message.id) || 0,
receiver: 0,
sender: sender.id,
createdAt: date,
});
yield models_1.models.MediaKey.create({
muid: json.muid,
chatId: chat.id,
key: encKey,
key: keyToSave,
messageId: (payload.message && payload.message.id) || 0,
receiver: 0,
sender: sender.id,
createdAt: date,
});
// await sleep(1)
// await models.MediaKey.create({
// muid:json.muid,
// chatId:chat.id,
// key:encKey,
// messageId: (payload.message&&payload.message.id)||0,
// receiver: 0,
// sender: sender.id, // the og sender
// createdAt: date,
// })
return fillmsg(payload, { mediaTerms, mediaKey: encKey }); // key is re-encrypted later
}
catch (e) {
@ -102,4 +105,7 @@ exports.modifyPayloadAndSaveMediaKey = modifyPayloadAndSaveMediaKey;
function fillmsg(full, props) {
return Object.assign(Object.assign({}, full), { message: Object.assign(Object.assign({}, full.message), props) });
}
// async function sleep(ms) {
// return new Promise(resolve => setTimeout(resolve, ms))
// }
//# sourceMappingURL=modify.js.map

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

@ -1 +1 @@
{"version":3,"file":"modify.js","sourceRoot":"","sources":["../../../api/network/modify.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA4B;AAC5B,kDAA0C;AAC1C,oCAAmC;AACnC,wCAAuC;AACvC,qCAAoC;AACpC,iCAAgC;AAChC,sCAAqC;AACrC,sCAAqC;AACrC,sCAAkC;AAElC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC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