Browse Source

fix sort replay

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
a3728a82fc
  1. 8
      api/controllers/chatTribes.ts
  2. 6
      dist/api/controllers/chatTribes.js
  3. 2
      dist/api/controllers/chatTribes.js.map

8
api/controllers/chatTribes.ts

@ -6,6 +6,7 @@ import * as rsa from '../crypto/rsa'
import * as tribes from '../utils/tribes'
import * as path from 'path'
import {personalizeMessage, decryptMessage} from '../utils/msg'
import { Op } from 'sequelize'
const constants = require(path.join(__dirname,'../../config/constants.json'))
@ -150,10 +151,11 @@ async function replayChatHistory(chat, contact) {
return console.log('[tribes] cant replay history')
}
const msgs = await models.Message.findAll({
where:{chatId:chat.id},
order: [['id', 'asc']],
limit:40
where:{chatId:chat.id, type:{[Op.in]:network.typesToReplay}},
order: [['id', 'desc']],
limit: 40
})
msgs.reverse()
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

6
dist/api/controllers/chatTribes.js

@ -17,6 +17,7 @@ const rsa = require("../crypto/rsa");
const tribes = require("../utils/tribes");
const path = require("path");
const msg_1 = require("../utils/msg");
const sequelize_1 = require("sequelize");
const constants = require(path.join(__dirname, '../../config/constants.json'));
function joinTribe(req, res) {
return __awaiter(this, void 0, void 0, function* () {
@ -148,10 +149,11 @@ function replayChatHistory(chat, contact) {
return console.log('[tribes] cant replay history');
}
const msgs = yield models_1.models.Message.findAll({
where: { chatId: chat.id },
order: [['id', 'asc']],
where: { chatId: chat.id, type: { [sequelize_1.Op.in]: network.typesToReplay } },
order: [['id', 'desc']],
limit: 40
});
msgs.reverse();
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))

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

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