Browse Source

try

bugfix/timeout-logging
Evan Feenstra 5 years ago
parent
commit
981f08c009
  1. 17
      api/controllers/chatTribes.ts
  2. 2
      api/network/send.ts
  3. 17
      dist/api/controllers/chatTribes.js
  4. 2
      dist/api/controllers/chatTribes.js.map
  5. 2
      dist/api/network/send.js
  6. 2
      dist/api/network/send.js.map

17
api/controllers/chatTribes.ts

@ -157,12 +157,14 @@ async function replayChatHistory(chat, contact) {
if(!(chat&&chat.id&&contact&&contact.id)){
return console.log('[tribes] cant replay history')
}
console.log('network.typesToReplay',network.typesToReplay)
const msgs = await models.Message.findAll({
where:{chatId:chat.id, type:{[Op.in]:network.typesToReplay}},
order: [['id', 'desc']],
limit: 40
})
msgs.reverse()
console.log('msgs.length',msgs.length)
const owner = await models.Contact.findOne({ where: { isOwner: true } })
asyncForEach(msgs, async m=>{
if(!network.typesToReplay.includes(m.type)) return // only for message for now
@ -179,12 +181,15 @@ async function replayChatHistory(chat, contact) {
if(m.type===constants.message_types.attachment) {
if(m.mediaKey&&m.mediaToken) {
const muid = m.mediaToken.split('.').length && m.mediaToken.split('.')[1]
const mediaKey = await models.MediaKey.findOne({where:{
muid, chatId: chat.id,
}})
// console.log("FOUND MEDIA KEY!!",mediaKey.dataValues)
mediaKeyMap = {chat: mediaKey.key}
newMediaTerms = {muid: mediaKey.muid}
console.log('muid',muid)
if(muid) {
const mediaKey = await models.MediaKey.findOne({where:{
muid, chatId: chat.id,
}})
// console.log("FOUND MEDIA KEY!!",mediaKey.dataValues)
mediaKeyMap = {chat: mediaKey.key}
newMediaTerms = {muid: mediaKey.muid}
}
}
}
let msg = network.newmsg(m.type, chat, sender, {

2
api/network/send.ts

@ -91,7 +91,7 @@ export async function sendMessage(params) {
}
export function signAndSend(opts, mqttTopic?:string){
// console.log('sign and send!!!!',opts.data)
console.log('sign and send!')
return new Promise(async function(resolve, reject) {
if(!opts || typeof opts!=='object') {
return reject('object plz')

17
dist/api/controllers/chatTribes.js

@ -153,12 +153,14 @@ function replayChatHistory(chat, contact) {
if (!(chat && chat.id && contact && contact.id)) {
return console.log('[tribes] cant replay history');
}
console.log('network.typesToReplay', network.typesToReplay);
const msgs = yield models_1.models.Message.findAll({
where: { chatId: chat.id, type: { [sequelize_1.Op.in]: network.typesToReplay } },
order: [['id', 'desc']],
limit: 40
});
msgs.reverse();
console.log('msgs.length', msgs.length);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
asyncForEach(msgs, (m) => __awaiter(this, void 0, void 0, function* () {
if (!network.typesToReplay.includes(m.type))
@ -175,12 +177,15 @@ function replayChatHistory(chat, contact) {
if (m.type === constants.message_types.attachment) {
if (m.mediaKey && m.mediaToken) {
const muid = m.mediaToken.split('.').length && m.mediaToken.split('.')[1];
const mediaKey = yield models_1.models.MediaKey.findOne({ where: {
muid, chatId: chat.id,
} });
// console.log("FOUND MEDIA KEY!!",mediaKey.dataValues)
mediaKeyMap = { chat: mediaKey.key };
newMediaTerms = { muid: mediaKey.muid };
console.log('muid', muid);
if (muid) {
const mediaKey = yield models_1.models.MediaKey.findOne({ where: {
muid, chatId: chat.id,
} });
// console.log("FOUND MEDIA KEY!!",mediaKey.dataValues)
mediaKeyMap = { chat: mediaKey.key };
newMediaTerms = { muid: mediaKey.muid };
}
}
}
let msg = network.newmsg(m.type, chat, sender, Object.assign(Object.assign(Object.assign(Object.assign({ content }, mediaKeyMap && { mediaKey: mediaKeyMap }), newMediaTerms && { mediaToken: newMediaTerms }), m.mediaType && { mediaType: m.mediaType }), dateString && { date: dateString }));

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

File diff suppressed because one or more lines are too long

2
dist/api/network/send.js

@ -100,7 +100,7 @@ function sendMessage(params) {
}
exports.sendMessage = sendMessage;
function signAndSend(opts, mqttTopic) {
// console.log('sign and send!!!!',opts.data)
console.log('sign and send!');
return new Promise(function (resolve, reject) {
return __awaiter(this, void 0, void 0, function* () {
if (!opts || typeof opts !== 'object') {

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

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