Browse Source

Merge pull request #54 from stakwork/kicker

del-msg
bugfix/timeout-logging v0.9.19
Evan Feenstra 5 years ago
committed by GitHub
parent
commit
83bff65bef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      api/controllers/chatTribes.ts
  2. 40
      api/controllers/chats.ts
  3. 1
      api/controllers/confirmations.ts
  4. 5
      api/controllers/index.ts
  5. 74
      api/controllers/messages.ts
  6. 32
      api/network/receive.ts
  7. 8
      api/network/send.ts
  8. 3
      api/utils/signer.ts
  9. 52
      api/utils/timers.ts
  10. 7
      config/constants.json
  11. 17
      dist/api/controllers/chatTribes.js
  12. 2
      dist/api/controllers/chatTribes.js.map
  13. 38
      dist/api/controllers/chats.js
  14. 2
      dist/api/controllers/chats.js.map
  15. 2
      dist/api/controllers/confirmations.js
  16. 2
      dist/api/controllers/confirmations.js.map
  17. 3
      dist/api/controllers/index.js
  18. 2
      dist/api/controllers/index.js.map
  19. 68
      dist/api/controllers/messages.js
  20. 2
      dist/api/controllers/messages.js.map
  21. 31
      dist/api/network/receive.js
  22. 2
      dist/api/network/receive.js.map
  23. 10
      dist/api/network/send.js
  24. 2
      dist/api/network/send.js.map
  25. 3
      dist/api/utils/signer.js
  26. 2
      dist/api/utils/signer.js.map
  27. 56
      dist/api/utils/timers.js
  28. 2
      dist/api/utils/timers.js.map
  29. 7
      dist/config/constants.json

17
api/controllers/chatTribes.ts

@ -178,12 +178,14 @@ 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}
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, {
@ -196,10 +198,11 @@ async function replayChatHistory(chat, contact) {
msg = await decryptMessage(msg, chat)
const data = await personalizeMessage(msg, contact, true)
const mqttTopic = `${contact.publicKey}/${chat.uuid}`
const replayingHistory = true
await network.signAndSend({
data,
dest: contact.publicKey,
}, mqttTopic)
}, mqttTopic, replayingHistory)
})
}

40
api/controllers/chats.ts

@ -8,10 +8,44 @@ import { sendNotification } from '../hub'
import * as md5 from 'md5'
import * as path from 'path'
import * as tribes from '../utils/tribes'
import * as timers from '../utils/timers'
import {replayChatHistory,createTribeChatParams} from './chatTribes'
const constants = require(path.join(__dirname,'../../config/constants.json'))
async function kickChatMember(req, res){
const chatId = parseInt(req.params['chat_id'])
const contactId = parseInt(req.params['contact_id'])
if(!chatId || !contactId) {
return failure(res, "missing param")
}
// remove chat.contactIds
let chat = await models.Chat.findOne({ where: { chatId } })
const contactIds = JSON.parse(chat.contactIds || '[]')
const newContactIds = contactIds.filter(cid=>cid!==contactId)
await chat.update({ contactIds: JSON.stringify(newContactIds) })
// remove from ChatMembers
await models.ChatMember.destroy({where:{
chatId, contactId,
}})
const contact = await models.Concat.findOne({where:{id:contactId}})
const members = {
[contact.publicKey]: {key:contact.contactKey, alias:contact.alias}
}
network.sendMessage({
chat: { ...chat.dataValues, contactIds:[contactId], members }, // send only to the guy u kicked
sender: contact,
message: {},
type: constants.message_types.group_leave,
})
// delete all timers for this member
timers.removeTimersByContactId(contactId)
success(res, true)
}
async function getChats(req, res) {
const chats = await models.Chat.findAll({ where:{deleted:false}, raw: true })
const c = chats.map(chat => jsonUtils.chatToJson(chat));
@ -219,6 +253,7 @@ async function receiveGroupJoin(payload) {
if(!isTribe || isTribeOwner) { // dont need to create contacts for these
const sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } })
console.log("sender",sender.dataValues)
const contactIds = JSON.parse(chat.contactIds || '[]')
if (sender) {
theSender = sender // might already include??
@ -318,6 +353,9 @@ async function receiveGroupLeave(payload) {
})
}
}
} else {
// check if im the only one in "members"
// and delete chat??
}
var date = new Date();
@ -474,7 +512,7 @@ function createGroupChatParams(owner, contactIds, members, name) {
}
export {
getChats, mute, addGroupMembers,
getChats, mute, addGroupMembers, kickChatMember,
receiveGroupCreateOrInvite, createGroupChat,
deleteChat, receiveGroupLeave, receiveGroupJoin,
}

1
api/controllers/confirmations.ts

@ -79,6 +79,7 @@ export async function receiveConfirmation(payload) {
}
export async function tribeOwnerAutoConfirmation(msg_id,chat_uuid){
if(!msg_id || !chat_uuid) return
const message = await models.Message.findOne({ where:{id:msg_id} })
const chat = await models.Chat.findOne({where:{uuid:chat_uuid}})
if(message){

5
api/controllers/index.ts

@ -38,6 +38,7 @@ async function set(app) {
app.post('/chats/:chat_id/:mute_unmute', chats.mute)
app.delete('/chat/:id', chats.deleteChat)
app.put('/chat/:id', chats.addGroupMembers)
app.put('/kick/:chat_id/:contact_id', chats.kickChatMember)
app.post('/tribe', chatTribes.joinTribe)
app.put('/group/:id', chatTribes.editTribe)
@ -130,7 +131,9 @@ const ACTIONS = {
[msgtypes.group_create]: chats.receiveGroupCreateOrInvite,
[msgtypes.group_invite]: chats.receiveGroupCreateOrInvite,
[msgtypes.group_join]: chats.receiveGroupJoin,
[msgtypes.group_leave]: chats.receiveGroupLeave,
[msgtypes.group_leave]: chats.receiveGroupLeave,
[msgtypes.delete]: messages.receiveDeleteMessage,
[msgtypes.repayment]: ()=>{},
}
export {set, ACTIONS}

74
api/controllers/messages.ts

@ -6,6 +6,7 @@ import * as socket from '../utils/socket'
import * as jsonUtils from '../utils/json'
import * as helpers from '../helpers'
import { success } from '../utils/res'
import * as timers from '../utils/timers'
import {sendConfirmation} from './confirmations'
import * as path from 'path'
import * as network from '../network'
@ -33,10 +34,19 @@ const getMessages = async (req, res) => {
let confirmedMessagesWhere = {
updated_at: { [Op.gte]: dateToReturn },
status: constants.statuses.received,
status: {[Op.or]: [
constants.statuses.received,
]},
sender: owner.id
}
let deletedMessagesWhere = {
updated_at: { [Op.gte]: dateToReturn },
status: {[Op.or]: [
constants.statuses.deleted
]},
}
// if (chatId) {
// newMessagesWhere.chat_id = chatId
// confirmedMessagesWhere.chat_id = chatId
@ -44,6 +54,7 @@ const getMessages = async (req, res) => {
const newMessages = await models.Message.findAll({ where: newMessagesWhere })
const confirmedMessages = await models.Message.findAll({ where: confirmedMessagesWhere })
const deletedMessages = await models.Message.findAll({ where: deletedMessagesWhere })
const chatIds: number[] = []
newMessages.forEach(m => {
@ -52,6 +63,9 @@ const getMessages = async (req, res) => {
confirmedMessages.forEach(m => {
if(!chatIds.includes(m.chatId)) chatIds.push(m.chatId)
})
deletedMessages.forEach(m => {
if(!chatIds.includes(m.chatId)) chatIds.push(m.chatId)
})
let chats = chatIds.length > 0 ? await models.Chat.findAll({ where: {deleted:false, id: chatIds} }) : []
const chatsById = indexBy(chats, 'id')
@ -64,6 +78,9 @@ const getMessages = async (req, res) => {
),
confirmed_messages: confirmedMessages.map(message =>
jsonUtils.messageToJson(message, chatsById[parseInt(message.chatId)])
),
deleted_messages: deletedMessages.map(message =>
jsonUtils.messageToJson(message, chatsById[parseInt(message.chatId)])
)
}
});
@ -90,9 +107,34 @@ const getAllMessages = async (req, res) => {
};
async function deleteMessage(req, res){
const id = req.params.id
await models.Message.destroy({ where: {id} })
success(res, {id})
const id = parseInt(req.params.id)
const message = await models.Message.findOne({where:{id}})
const uuid = message.uuid
await message.update({status: constants.statuses.deleted})
const chat_id = message.chatId
let chat
if(chat_id) {
chat = await models.Chat.findOne({where:{id:chat_id}})
}
success(res, jsonUtils.messageToJson(message, chat))
if(!chat) return
const isTribe = chat.type===constants.chat_types.tribe
const owner = await models.Contact.findOne({ where: { isOwner: true }})
const isTribeOwner = isTribe && owner.publicKey===chat.ownerPubkey
if(isTribeOwner) {
timers.removeTimerByMsgId(id)
}
network.sendMessage({
chat: chat,
sender: owner,
type: constants.message_types.delete,
message: {id,uuid},
})
}
const sendMessage = async (req, res) => {
@ -204,6 +246,29 @@ const receiveMessage = async (payload) => {
sendConfirmation({ chat:theChat, sender: owner, msg_id })
}
const receiveDeleteMessage = async (payload) => {
console.log('=> received delete message')
const {owner, sender, chat, chat_type, msg_uuid} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
const isTribe = chat_type===constants.chat_types.tribe
// in tribe this is already validated on admin's node
let where:{[k:string]:any} = {uuid: msg_uuid}
if(!isTribe) {
where.sender = sender.id // validate sender
}
const message = await models.Message.findOne({where})
if(!message) return
await message.update({status: constants.statuses.deleted})
socket.sendJson({
type: 'delete',
response: jsonUtils.messageToJson(message, chat, sender)
})
}
const readMessages = async (req, res) => {
const chat_id = req.params.chat_id;
@ -235,4 +300,5 @@ export {
readMessages,
deleteMessage,
getAllMessages,
receiveDeleteMessage,
}

32
api/network/receive.ts

@ -13,11 +13,17 @@ import {decryptMessage,encryptTribeBroadcast} from '../utils/msg'
import { Op } from 'sequelize'
import * as timers from '../utils/timers'
/*
delete type:
owner needs to check that the delete is the one who made the msg
in receiveDeleteMessage check the deleter is og sender?
*/
const constants = require(path.join(__dirname,'../../config/constants.json'))
const msgtypes = constants.message_types
export const typesToForward=[
msgtypes.message, msgtypes.group_join, msgtypes.group_leave, msgtypes.attachment
msgtypes.message, msgtypes.group_join, msgtypes.group_leave, msgtypes.attachment, msgtypes.delete
]
const typesToModify=[
msgtypes.attachment
@ -70,6 +76,17 @@ async function onReceive(payload){
if(payload.type===msgtypes.group_join) {
if(payload.message.amount<chat.priceToJoin) doAction=false
}
// check that the sender is the og poster
if(payload.type===msgtypes.delete) {
doAction = false
if(payload.message.uuid) {
const ogMsg = await models.Message.findOne({where:{
uuid: payload.message.uuid,
sender: senderContact.id,
}})
if(ogMsg) doAction = true
}
}
if(doAction) forwardMessageToTribe(payload, senderContact)
else console.log('=> insufficient payment for this action')
}
@ -120,15 +137,21 @@ async function doTheAction(data){
}
async function forwardMessageToTribe(ogpayload, sender){
// console.log('forwardMessageToTribe')
const chat = await models.Chat.findOne({where:{uuid:ogpayload.chat.uuid}})
let contactIds = JSON.parse(chat.contactIds||'[]')
contactIds = contactIds.filter(cid=>cid!==sender.id)
if(contactIds.length===0) {
return // totally skip if only send is in tribe
}
let payload
if(typesToModify.includes(ogpayload.type)){
payload = await modifyPayloadAndSaveMediaKey(ogpayload, chat, sender)
} else {
payload = ogpayload
}
//console.log("FORWARD TO TRIBE",payload) // filter out the sender?
//const sender = await models.Contact.findOne({where:{publicKey:payload.sender.pub_key}})
const owner = await models.Contact.findOne({where:{isOwner:true}})
@ -137,11 +160,12 @@ async function forwardMessageToTribe(ogpayload, sender){
// HERE: NEED TO MAKE SURE ALIAS IS UNIQUE
// ASK xref TABLE and put alias there too?
sendMessage({
type, message,
sender: {
...owner.dataValues,
...payload.sender&&payload.sender.alias && {alias:payload.sender.alias}
},
chat, type, message,
chat: {...chat.dataValues, contactIds},
skipPubKey: payload.sender.pub_key,
success: ()=>{},
receive: ()=>{}
@ -179,7 +203,7 @@ async function parseAndVerifyPayload(data){
payload = JSON.parse(msg)
if(payload && payload.sender && payload.sender.pub_key) {
let v
if(sig.length===96) { // => RM THIS
if(sig.length===96 && payload.sender.pub_key) { // => RM THIS
v = await signer.verifyAscii(msg, sig, payload.sender.pub_key)
}
if(v && v.valid) {

8
api/network/send.ts

@ -90,8 +90,8 @@ export async function sendMessage(params) {
}
}
export function signAndSend(opts, mqttTopic?:string){
// console.log('sign and send!!!!',opts.data)
export function signAndSend(opts, mqttTopic?:string, replayingHistory?:boolean){
// console.log('sign and send!',opts)
return new Promise(async function(resolve, reject) {
if(!opts || typeof opts!=='object') {
return reject('object plz')
@ -109,7 +109,9 @@ export function signAndSend(opts, mqttTopic?:string){
try {
if(mqttTopic) {
await tribes.publish(mqttTopic, data, function(){
if(mqttTopic) checkIfAutoConfirm(opts.data)
if(!replayingHistory){
if(mqttTopic) checkIfAutoConfirm(opts.data)
}
})
} else {
await LND.keysendMessage({...opts,data})

3
api/utils/signer.ts

@ -70,6 +70,9 @@ export const signBuffer = (msg) => {
function verifyMessage(msg,sig,pubkey): Promise<{[k:string]:any}> {
return new Promise(async(resolve, reject)=> {
let signer = await loadSigner()
if(msg.length===0) {
return reject('invalid msg')
}
if(sig.length!==96) {
return reject('invalid sig')
}

52
api/utils/timers.ts

@ -4,41 +4,71 @@ import * as path from 'path'
const constants = require(path.join(__dirname,'../../config/constants.json'))
const timerz={}
function clearTimer(t){
const name = makeName(t)
if(name) clearTimeout(timerz[name])
}
export async function removeTimerByMsgId(msgId){
const t = await models.Timer.findOne({where:{msgId}})
clearTimer(t)
models.Timer.destroy({where:{msgId}})
}
export async function removeTimersByContactId(contactId){
const ts = await models.Timer.findAll({where:{receiver:contactId}})
ts.forEach(t=> clearTimer(t))
models.Timer.destroy({where:{receiver:contactId}})
}
export async function addTimer({amount, millis, receiver, msgId, chatId}){
const now = new Date().valueOf()
const when = now + millis
const t = await models.Timer.create({
amount, millis:when, receiver, msgId, chatId,
})
setTimer(when, async ()=>{
setTimer(makeName(t), when, async ()=>{
payBack(t)
})
}
export function setTimer(when:number, cb){
export function setTimer(name:string, when:number, cb){
const now = new Date().valueOf()
const ms = when-now
if(ms<0) cb() // fire right away if its already passed
else setTimeout(cb, ms)
if(ms<0) {
cb() // fire right away if its already passed
} else {
timerz[name] = setTimeout(cb, ms)
}
}
function makeName(t){
if(!t) return ''
return `${t.chatId}_${t.receiver}_${t.msgId}`
}
export async function reloadTimers(){
const timers = await models.Timer.findAll()
timers && timers.forEach(t=>{
setTimer(t.millis, async ()=>{
payBack(t)
const timers = await models.Timer.findAll()
timers && timers.forEach((t,i)=>{
const name = makeName(t)
setTimer(name, t.millis, async ()=>{
setTimeout(()=>{
payBack(t)
},i*420) // dont do all at once
})
})
}
export async function payBack(t){
const chat = await models.Chat.findOne({ where: {id:t.chatId} })
const owner = await models.Contact.findOne({ where: {isOwner:true} })
if(!chat) return
if(!chat) {
models.Timer.destroy({where:{id:t.id}})
return
}
const theChat = {...chat.dataValues, contactIds:[t.receiver]}
network.sendMessage({
chat: theChat,
sender: owner,
message: {id:t.msgId},
message: {id:t.msgId,amount:t.amount},
amount: t.amount,
type: constants.message_types.confirmation,
type: constants.message_types.repayment,
})
models.Timer.destroy({where:{id:t.id}})
}

7
config/constants.json

@ -17,7 +17,8 @@
"confirmed": 1,
"cancelled": 2,
"received": 3,
"failed": 4
"failed": 4,
"deleted": 5
},
"message_types": {
"message": 0,
@ -36,7 +37,9 @@
"group_invite": 13,
"group_join": 14,
"group_leave": 15,
"group_query": 16
"group_query": 16,
"delete": 17,
"repayment": 18
},
"payment_errors": {
"timeout": "Timed Out",

17
dist/api/controllers/chatTribes.js

@ -174,22 +174,25 @@ 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 };
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 }));
msg = yield msg_1.decryptMessage(msg, chat);
const data = yield msg_1.personalizeMessage(msg, contact, true);
const mqttTopic = `${contact.publicKey}/${chat.uuid}`;
const replayingHistory = true;
yield network.signAndSend({
data,
dest: contact.publicKey,
}, mqttTopic);
}, mqttTopic, replayingHistory);
}));
});
}

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

File diff suppressed because one or more lines are too long

38
dist/api/controllers/chats.js

@ -19,8 +19,41 @@ const hub_1 = require("../hub");
const md5 = require("md5");
const path = require("path");
const tribes = require("../utils/tribes");
const timers = require("../utils/timers");
const chatTribes_1 = require("./chatTribes");
const constants = require(path.join(__dirname, '../../config/constants.json'));
function kickChatMember(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const chatId = parseInt(req.params['chat_id']);
const contactId = parseInt(req.params['contact_id']);
if (!chatId || !contactId) {
return res_1.failure(res, "missing param");
}
// remove chat.contactIds
let chat = yield models_1.models.Chat.findOne({ where: { chatId } });
const contactIds = JSON.parse(chat.contactIds || '[]');
const newContactIds = contactIds.filter(cid => cid !== contactId);
yield chat.update({ contactIds: JSON.stringify(newContactIds) });
// remove from ChatMembers
yield models_1.models.ChatMember.destroy({ where: {
chatId, contactId,
} });
const contact = yield models_1.models.Concat.findOne({ where: { id: contactId } });
const members = {
[contact.publicKey]: { key: contact.contactKey, alias: contact.alias }
};
network.sendMessage({
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds: [contactId], members }),
sender: contact,
message: {},
type: constants.message_types.group_leave,
});
// delete all timers for this member
timers.removeTimersByContactId(contactId);
res_1.success(res, true);
});
}
exports.kickChatMember = kickChatMember;
function getChats(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const chats = yield models_1.models.Chat.findAll({ where: { deleted: false }, raw: true });
@ -208,6 +241,7 @@ function receiveGroupJoin(payload) {
const senderAlias = sender_alias || (member && member.alias) || 'Unknown';
if (!isTribe || isTribeOwner) { // dont need to create contacts for these
const sender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pub_key } });
console.log("sender", sender.dataValues);
const contactIds = JSON.parse(chat.contactIds || '[]');
if (sender) {
theSender = sender; // might already include??
@ -307,6 +341,10 @@ function receiveGroupLeave(payload) {
}
}
}
else {
// check if im the only one in "members"
// and delete chat??
}
var date = new Date();
date.setMilliseconds(0);
if (date_string)

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

File diff suppressed because one or more lines are too long

2
dist/api/controllers/confirmations.js

@ -90,6 +90,8 @@ function receiveConfirmation(payload) {
exports.receiveConfirmation = receiveConfirmation;
function tribeOwnerAutoConfirmation(msg_id, chat_uuid) {
return __awaiter(this, void 0, void 0, function* () {
if (!msg_id || !chat_uuid)
return;
const message = yield models_1.models.Message.findOne({ where: { id: msg_id } });
const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (message) {

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

@ -1 +1 @@
{"version":3,"file":"confirmations.js","sourceRoot":"","sources":["../../../api/controllers/confirmations.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wCAAgC;AAChC,sCAAgC;AAChC,0CAAyC;AACzC,2CAA0C;AAC1C,sCAAqC;AACrC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAE7E,SAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE;IACxD,IAAG,CAAC,MAAM;QAAE,OAAM;IAClB,OAAO,CAAC,WAAW,CAAC;QACnB,IAAI;QACJ,MAAM;QACN,OAAO,EAAE,EAAC,EAAE,EAAC,MAAM,EAAC;QACpB,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,YAAY;KAC1C,CAAC,CAAA;AACH,CAAC;AARD,4CAQC;AAED,SAAsB,mBAAmB,CAAC,OAAO;;QAChD,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,CAAC,OAAO,CAAC,OAAO,IAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;QAE9E,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAA;QACtC,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAA;QAC/B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CA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app.delete('/chat/:id', chats.deleteChat);
app.put('/chat/:id', chats.addGroupMembers);
app.put('/kick/:chat_id/:contact_id', chats.kickChatMember);
app.post('/tribe', chatTribes.joinTribe);
app.put('/group/:id', chatTribes.editTribe);
app.post('/upload', uploads.avatarUpload.single('file'), uploads.uploadFile);
@ -129,6 +130,8 @@ const ACTIONS = {
[msgtypes.group_invite]: chats.receiveGroupCreateOrInvite,
[msgtypes.group_join]: chats.receiveGroupJoin,
[msgtypes.group_leave]: chats.receiveGroupLeave,
[msgtypes.delete]: messages.receiveDeleteMessage,
[msgtypes.repayment]: () => { },
};
exports.ACTIONS = ACTIONS;
//# sourceMappingURL=index.js.map

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

File diff suppressed because one or more lines are too long

68
dist/api/controllers/messages.js

@ -17,6 +17,7 @@ const socket = require("../utils/socket");
const jsonUtils = require("../utils/json");
const helpers = require("../helpers");
const res_1 = require("../utils/res");
const timers = require("../utils/timers");
const confirmations_1 = require("./confirmations");
const path = require("path");
const network = require("../network");
@ -39,15 +40,24 @@ const getMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
};
let confirmedMessagesWhere = {
updated_at: { [sequelize_1.Op.gte]: dateToReturn },
status: constants.statuses.received,
status: { [sequelize_1.Op.or]: [
constants.statuses.received,
] },
sender: owner.id
};
let deletedMessagesWhere = {
updated_at: { [sequelize_1.Op.gte]: dateToReturn },
status: { [sequelize_1.Op.or]: [
constants.statuses.deleted
] },
};
// if (chatId) {
// newMessagesWhere.chat_id = chatId
// confirmedMessagesWhere.chat_id = chatId
// }
const newMessages = yield models_1.models.Message.findAll({ where: newMessagesWhere });
const confirmedMessages = yield models_1.models.Message.findAll({ where: confirmedMessagesWhere });
const deletedMessages = yield models_1.models.Message.findAll({ where: deletedMessagesWhere });
const chatIds = [];
newMessages.forEach(m => {
if (!chatIds.includes(m.chatId))
@ -57,13 +67,18 @@ const getMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
if (!chatIds.includes(m.chatId))
chatIds.push(m.chatId);
});
deletedMessages.forEach(m => {
if (!chatIds.includes(m.chatId))
chatIds.push(m.chatId);
});
let chats = chatIds.length > 0 ? yield models_1.models.Chat.findAll({ where: { deleted: false, id: chatIds } }) : [];
const chatsById = underscore_1.indexBy(chats, 'id');
res.json({
success: true,
response: {
new_messages: newMessages.map(message => jsonUtils.messageToJson(message, chatsById[parseInt(message.chatId)])),
confirmed_messages: confirmedMessages.map(message => jsonUtils.messageToJson(message, chatsById[parseInt(message.chatId)]))
confirmed_messages: confirmedMessages.map(message => jsonUtils.messageToJson(message, chatsById[parseInt(message.chatId)])),
deleted_messages: deletedMessages.map(message => jsonUtils.messageToJson(message, chatsById[parseInt(message.chatId)]))
}
});
res.status(200);
@ -86,9 +101,30 @@ const getAllMessages = (req, res) => __awaiter(void 0, void 0, void 0, function*
exports.getAllMessages = getAllMessages;
function deleteMessage(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const id = req.params.id;
yield models_1.models.Message.destroy({ where: { id } });
res_1.success(res, { id });
const id = parseInt(req.params.id);
const message = yield models_1.models.Message.findOne({ where: { id } });
const uuid = message.uuid;
yield message.update({ status: constants.statuses.deleted });
const chat_id = message.chatId;
let chat;
if (chat_id) {
chat = yield models_1.models.Chat.findOne({ where: { id: chat_id } });
}
res_1.success(res, jsonUtils.messageToJson(message, chat));
if (!chat)
return;
const isTribe = chat.type === constants.chat_types.tribe;
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const isTribeOwner = isTribe && owner.publicKey === chat.ownerPubkey;
if (isTribeOwner) {
timers.removeTimerByMsgId(id);
}
network.sendMessage({
chat: chat,
sender: owner,
type: constants.message_types.delete,
message: { id, uuid },
});
});
}
exports.deleteMessage = deleteMessage;
@ -185,6 +221,28 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
});
exports.receiveMessage = receiveMessage;
const receiveDeleteMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> received delete message');
const { owner, sender, chat, chat_type, msg_uuid } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
const isTribe = chat_type === constants.chat_types.tribe;
// in tribe this is already validated on admin's node
let where = { uuid: msg_uuid };
if (!isTribe) {
where.sender = sender.id; // validate sender
}
const message = yield models_1.models.Message.findOne({ where });
if (!message)
return;
yield message.update({ status: constants.statuses.deleted });
socket.sendJson({
type: 'delete',
response: jsonUtils.messageToJson(message, chat, sender)
});
});
exports.receiveDeleteMessage = receiveDeleteMessage;
const readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const chat_id = req.params.chat_id;
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });

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

File diff suppressed because one or more lines are too long

31
dist/api/network/receive.js

@ -23,10 +23,15 @@ const modify_1 = require("./modify");
const msg_1 = require("../utils/msg");
const sequelize_1 = require("sequelize");
const timers = require("../utils/timers");
/*
delete type:
owner needs to check that the delete is the one who made the msg
in receiveDeleteMessage check the deleter is og sender?
*/
const constants = require(path.join(__dirname, '../../config/constants.json'));
const msgtypes = constants.message_types;
exports.typesToForward = [
msgtypes.message, msgtypes.group_join, msgtypes.group_leave, msgtypes.attachment
msgtypes.message, msgtypes.group_join, msgtypes.group_leave, msgtypes.attachment, msgtypes.delete
];
const typesToModify = [
msgtypes.attachment
@ -84,6 +89,18 @@ function onReceive(payload) {
if (payload.message.amount < chat.priceToJoin)
doAction = false;
}
// check that the sender is the og poster
if (payload.type === msgtypes.delete) {
doAction = false;
if (payload.message.uuid) {
const ogMsg = yield models_1.models.Message.findOne({ where: {
uuid: payload.message.uuid,
sender: senderContact.id,
} });
if (ogMsg)
doAction = true;
}
}
if (doAction)
forwardMessageToTribe(payload, senderContact);
else
@ -141,7 +158,13 @@ function doTheAction(data) {
}
function forwardMessageToTribe(ogpayload, sender) {
return __awaiter(this, void 0, void 0, function* () {
// console.log('forwardMessageToTribe')
const chat = yield models_1.models.Chat.findOne({ where: { uuid: ogpayload.chat.uuid } });
let contactIds = JSON.parse(chat.contactIds || '[]');
contactIds = contactIds.filter(cid => cid !== sender.id);
if (contactIds.length === 0) {
return; // totally skip if only send is in tribe
}
let payload;
if (typesToModify.includes(ogpayload.type)) {
payload = yield modify_1.modifyPayloadAndSaveMediaKey(ogpayload, chat, sender);
@ -149,7 +172,6 @@ function forwardMessageToTribe(ogpayload, sender) {
else {
payload = ogpayload;
}
//console.log("FORWARD TO TRIBE",payload) // filter out the sender?
//const sender = await models.Contact.findOne({where:{publicKey:payload.sender.pub_key}})
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const type = payload.type;
@ -157,8 +179,9 @@ function forwardMessageToTribe(ogpayload, sender) {
// HERE: NEED TO MAKE SURE ALIAS IS UNIQUE
// ASK xref TABLE and put alias there too?
send_1.sendMessage({
type, message,
sender: Object.assign(Object.assign({}, owner.dataValues), payload.sender && payload.sender.alias && { alias: payload.sender.alias }),
chat, type, message,
chat: Object.assign(Object.assign({}, chat.dataValues), { contactIds }),
skipPubKey: payload.sender.pub_key,
success: () => { },
receive: () => { }
@ -203,7 +226,7 @@ function parseAndVerifyPayload(data) {
payload = JSON.parse(msg);
if (payload && payload.sender && payload.sender.pub_key) {
let v;
if (sig.length === 96) { // => RM THIS
if (sig.length === 96 && payload.sender.pub_key) { // => RM THIS
v = yield signer.verifyAscii(msg, sig, payload.sender.pub_key);
}
if (v && v.valid) {

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

File diff suppressed because one or more lines are too long

10
dist/api/network/send.js

@ -99,8 +99,8 @@ function sendMessage(params) {
});
}
exports.sendMessage = sendMessage;
function signAndSend(opts, mqttTopic) {
// console.log('sign and send!!!!',opts.data)
function signAndSend(opts, mqttTopic, replayingHistory) {
// console.log('sign and send!',opts)
return new Promise(function (resolve, reject) {
return __awaiter(this, void 0, void 0, function* () {
if (!opts || typeof opts !== 'object') {
@ -117,8 +117,10 @@ function signAndSend(opts, mqttTopic) {
try {
if (mqttTopic) {
yield tribes.publish(mqttTopic, data, function () {
if (mqttTopic)
checkIfAutoConfirm(opts.data);
if (!replayingHistory) {
if (mqttTopic)
checkIfAutoConfirm(opts.data);
}
});
}
else {

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

File diff suppressed because one or more lines are too long

3
dist/api/utils/signer.js

@ -80,6 +80,9 @@ exports.signBuffer = (msg) => {
function verifyMessage(msg, sig, pubkey) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
let signer = yield exports.loadSigner();
if (msg.length === 0) {
return reject('invalid msg');
}
if (sig.length !== 96) {
return reject('invalid sig');
}

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

@ -1 +1 @@
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../api/utils/signer.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,6BAA4B;AAC5B,2CAA2C;AAC3C,6BAA4B;AAC5B,yCAAwC;AAExC,kDAAkD;AAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;AAClD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzE,IAAI,YAAY,GAAS,IAAI,CAAC;AAEjB,QAAA,UAAU,GAAG,GAAG,EAAE;IAC7B,IAAI,YAAY,EAAE;QAChB,OAAO,YAAY,CAAA;KACpB;SAAM;QACL,IAAG;YACD,IAAI,WAAW,GAAG,2BAAe,EAAE,CAAA;YACnC,IAAI,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAChD,IAAI,MAAM,GAAQ,eAAe,CAAC,OAAO,CAAA;YACzC,YAAY,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YACtF,OAAO,YAAY,CAAA;SACpB;QAAC,OAAM,CAAC,E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EAAE;QAC5C,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACd;IACF,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC"}

56
dist/api/utils/timers.js

@ -13,6 +13,28 @@ const models_1 = require("../models");
const network = require("../network");
const path = require("path");
const constants = require(path.join(__dirname, '../../config/constants.json'));
const timerz = {};
function clearTimer(t) {
const name = makeName(t);
if (name)
clearTimeout(timerz[name]);
}
function removeTimerByMsgId(msgId) {
return __awaiter(this, void 0, void 0, function* () {
const t = yield models_1.models.Timer.findOne({ where: { msgId } });
clearTimer(t);
models_1.models.Timer.destroy({ where: { msgId } });
});
}
exports.removeTimerByMsgId = removeTimerByMsgId;
function removeTimersByContactId(contactId) {
return __awaiter(this, void 0, void 0, function* () {
const ts = yield models_1.models.Timer.findAll({ where: { receiver: contactId } });
ts.forEach(t => clearTimer(t));
models_1.models.Timer.destroy({ where: { receiver: contactId } });
});
}
exports.removeTimersByContactId = removeTimersByContactId;
function addTimer({ amount, millis, receiver, msgId, chatId }) {
return __awaiter(this, void 0, void 0, function* () {
const now = new Date().valueOf();
@ -20,27 +42,37 @@ function addTimer({ amount, millis, receiver, msgId, chatId }) {
const t = yield models_1.models.Timer.create({
amount, millis: when, receiver, msgId, chatId,
});
setTimer(when, () => __awaiter(this, void 0, void 0, function* () {
setTimer(makeName(t), when, () => __awaiter(this, void 0, void 0, function* () {
payBack(t);
}));
});
}
exports.addTimer = addTimer;
function setTimer(when, cb) {
function setTimer(name, when, cb) {
const now = new Date().valueOf();
const ms = when - now;
if (ms < 0)
if (ms < 0) {
cb(); // fire right away if its already passed
else
setTimeout(cb, ms);
}
else {
timerz[name] = setTimeout(cb, ms);
}
}
exports.setTimer = setTimer;
function makeName(t) {
if (!t)
return '';
return `${t.chatId}_${t.receiver}_${t.msgId}`;
}
function reloadTimers() {
return __awaiter(this, void 0, void 0, function* () {
const timers = yield models_1.models.Timer.findAll();
timers && timers.forEach(t => {
setTimer(t.millis, () => __awaiter(this, void 0, void 0, function* () {
payBack(t);
timers && timers.forEach((t, i) => {
const name = makeName(t);
setTimer(name, t.millis, () => __awaiter(this, void 0, void 0, function* () {
setTimeout(() => {
payBack(t);
}, i * 420); // dont do all at once
}));
});
});
@ -50,15 +82,17 @@ function payBack(t) {
return __awaiter(this, void 0, void 0, function* () {
const chat = yield models_1.models.Chat.findOne({ where: { id: t.chatId } });
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
if (!chat)
if (!chat) {
models_1.models.Timer.destroy({ where: { id: t.id } });
return;
}
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [t.receiver] });
network.sendMessage({
chat: theChat,
sender: owner,
message: { id: t.msgId },
message: { id: t.msgId, amount: t.amount },
amount: t.amount,
type: constants.message_types.confirmation,
type: constants.message_types.repayment,
});
models_1.models.Timer.destroy({ where: { id: t.id } });
});

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

@ -1 +1 @@
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../../../api/utils/timers.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAkC;AAClC,sCAAqC;AACrC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAE7E,SAAsB,QAAQ,CAAC,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAC;;QACpE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QAChC,MAAM,IAAI,GAAG,GAAG,GAAG,MAAM,CAAA;QACzB,MAAM,CAAC,GAAG,MAAM,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YAChC,MAAM,EAAE,MAAM,EAAC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AAE,UAAU,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAC,CAAA;QAC7D,OAAO,CAAC,WAAW,CAAC;YAChB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAC,EAAE,EAAC,CAAC,CAAC,KAAK,EAAC,MAAM,EAAC,CAAC,CAAC,MAAM,EAAC;YACrC,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,SAAS;SAC1C,CAAC,CAAA;QACF,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC,EAAC,EAAE,EAAC,CAAC,CAAC,EAAE,EAAC,EAAC,CAAC,CAAA;IAC3C,CAAC;CAAA;AAhBD,0BAgBC"}

7
dist/config/constants.json

@ -17,7 +17,8 @@
"confirmed": 1,
"cancelled": 2,
"received": 3,
"failed": 4
"failed": 4,
"deleted": 5
},
"message_types": {
"message": 0,
@ -36,7 +37,9 @@
"group_invite": 13,
"group_join": 14,
"group_leave": 15,
"group_query": 16
"group_query": 16,
"delete": 17,
"repayment": 18
},
"payment_errors": {
"timeout": "Timed Out",

Loading…
Cancel
Save