Browse Source

fix sql

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

13
api/controllers/chatTribes.ts

@ -16,12 +16,12 @@ async function joinTribe(req, res){
const existing = await models.Chat.findOne({where:{uuid}})
if(existing) {
console.log('[tribes] u are already in this tribe')
return
return failure(res, 'cant find tribe')
}
if(!owner_pubkey || !group_key || !uuid) {
console.log('[tribes] missing required params')
return
return failure(res, 'missing required params')
}
const ownerPubKey = owner_pubkey
@ -148,7 +148,14 @@ async function editTribe(req, res) {
async function replayChatHistory(chat, contact) {
console.log('=> test replay')
const msgs = await models.Message.findAll({ order: [['id', 'asc']], limit:40 })
if(!(chat&&chat.id&&contact&&contact.id)){
console.log('[tribes] cant replay history')
}
const msgs = await models.Message.findAll({
where:{chatId:chat.id},
order: [['id', 'asc']],
limit:40
})
const owner = await models.Contact.findOne({ where: { isOwner: true } })
asyncForEach(msgs, async m=>{
const sender = {

13
dist/api/controllers/chatTribes.js

@ -25,11 +25,11 @@ function joinTribe(req, res) {
const existing = yield models_1.models.Chat.findOne({ where: { uuid } });
if (existing) {
console.log('[tribes] u are already in this tribe');
return;
return res_1.failure(res, 'cant find tribe');
}
if (!owner_pubkey || !group_key || !uuid) {
console.log('[tribes] missing required params');
return;
return res_1.failure(res, 'missing required params');
}
const ownerPubKey = owner_pubkey;
// verify signature here?
@ -145,7 +145,14 @@ exports.editTribe = editTribe;
function replayChatHistory(chat, contact) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> test replay');
const msgs = yield models_1.models.Message.findAll({ order: [['id', 'asc']], limit: 40 });
if (!(chat && chat.id && contact && contact.id)) {
console.log('[tribes] cant replay history');
}
const msgs = yield models_1.models.Message.findAll({
where: { chatId: chat.id },
order: [['id', 'asc']],
limit: 40
});
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
asyncForEach(msgs, (m) => __awaiter(this, void 0, void 0, function* () {
const sender = Object.assign(Object.assign({}, owner.dataValues), m.senderAlias && { alias: m.senderAlias });

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

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