Browse Source

kick user from tribe, respond to kickedout msg

bugfix/timeout-logging
Evan Feenstra 5 years ago
parent
commit
4d07e61cc2
  1. 15
      api/controllers/chatTribes.ts
  2. 60
      api/controllers/chats.ts
  3. 26
      api/controllers/contacts.ts
  4. 21
      api/controllers/details.ts
  5. 6
      api/controllers/index.ts
  6. 11
      api/controllers/invites.ts
  7. 18
      api/controllers/invoices.ts
  8. 38
      api/controllers/media.ts
  9. 27
      api/controllers/messages.ts
  10. 11
      api/controllers/payment.ts
  11. 12
      api/controllers/schemas.ts
  12. 29
      api/controllers/subscriptions.ts
  13. 9
      api/controllers/uploads.ts
  14. 5
      api/grpc/index.ts
  15. 24
      api/helpers.ts
  16. 2
      dist/api/controllers/chatTribes.js.map
  17. 39
      dist/api/controllers/chats.js
  18. 2
      dist/api/controllers/chats.js.map
  19. 24
      dist/api/controllers/contacts.js
  20. 2
      dist/api/controllers/contacts.js.map
  21. 15
      dist/api/controllers/details.js
  22. 2
      dist/api/controllers/details.js.map
  23. 3
      dist/api/controllers/index.js
  24. 2
      dist/api/controllers/index.js.map
  25. 9
      dist/api/controllers/invites.js
  26. 2
      dist/api/controllers/invites.js.map
  27. 15
      dist/api/controllers/invoices.js
  28. 2
      dist/api/controllers/invoices.js.map
  29. 21
      dist/api/controllers/media.js
  30. 2
      dist/api/controllers/media.js.map
  31. 23
      dist/api/controllers/messages.js
  32. 2
      dist/api/controllers/messages.js.map
  33. 9
      dist/api/controllers/payment.js
  34. 2
      dist/api/controllers/payment.js.map
  35. 9
      dist/api/controllers/schemas.js
  36. 2
      dist/api/controllers/schemas.js.map
  37. 9
      dist/api/controllers/subscriptions.js
  38. 2
      dist/api/controllers/subscriptions.js.map
  39. 6
      dist/api/controllers/uploads.js
  40. 2
      dist/api/controllers/uploads.js.map
  41. 2
      dist/api/grpc/index.js.map
  42. 13
      dist/api/helpers.js
  43. 2
      dist/api/helpers.js.map
  44. 11
      dist/public/index.html
  45. 86159
      dist/public/js/app.js
  46. BIN
      dist/public/relay.jpg
  47. 372
      dist/public/semantic.min.css

15
api/controllers/chatTribes.ts

@ -10,7 +10,7 @@ import { Op } from 'sequelize'
const constants = require(path.join(__dirname,'../../config/constants.json')) const constants = require(path.join(__dirname,'../../config/constants.json'))
async function joinTribe(req, res){ export async function joinTribe(req, res){
console.log('=> joinTribe') console.log('=> joinTribe')
const { uuid, group_key, name, host, amount, img, owner_pubkey, owner_alias } = req.body const { uuid, group_key, name, host, amount, img, owner_pubkey, owner_alias } = req.body
@ -93,7 +93,7 @@ async function joinTribe(req, res){
}) })
} }
async function editTribe(req, res) { export async function editTribe(req, res) {
const { const {
name, name,
is_listed, is_listed,
@ -152,7 +152,7 @@ async function editTribe(req, res) {
} }
} }
async function replayChatHistory(chat, contact) { export async function replayChatHistory(chat, contact) {
if(!(chat&&chat.id&&contact&&contact.id)){ if(!(chat&&chat.id&&contact&&contact.id)){
return console.log('[tribes] cant replay history') return console.log('[tribes] cant replay history')
} }
@ -206,8 +206,7 @@ async function replayChatHistory(chat, contact) {
}) })
} }
export async function createTribeChatParams(owner, contactIds, name, img, price_per_message, price_to_join, escrow_amount, escrow_millis): Promise<{[k:string]:any}> {
async function createTribeChatParams(owner, contactIds, name, img, price_per_message, price_to_join, escrow_amount, escrow_millis): Promise<{[k:string]:any}> {
let date = new Date() let date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
if (!(owner && contactIds && Array.isArray(contactIds))) { if (!(owner && contactIds && Array.isArray(contactIds))) {
@ -237,12 +236,6 @@ async function createTribeChatParams(owner, contactIds, name, img, price_per_mes
} }
} }
export {
joinTribe, editTribe,
replayChatHistory,
createTribeChatParams
}
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);

60
api/controllers/chats.ts

@ -13,7 +13,7 @@ import {replayChatHistory,createTribeChatParams} from './chatTribes'
const constants = require(path.join(__dirname,'../../config/constants.json')) const constants = require(path.join(__dirname,'../../config/constants.json'))
async function kickChatMember(req, res){ export async function kickChatMember(req, res){
const chatId = parseInt(req.params['chat_id']) const chatId = parseInt(req.params['chat_id'])
const contactId = parseInt(req.params['contact_id']) const contactId = parseInt(req.params['contact_id'])
if(!chatId || !contactId) { if(!chatId || !contactId) {
@ -46,13 +46,13 @@ async function kickChatMember(req, res){
success(res, true) success(res, true)
} }
async function getChats(req, res) { export async function getChats(req, res) {
const chats = await models.Chat.findAll({ where:{deleted:false}, raw: true }) const chats = await models.Chat.findAll({ where:{deleted:false}, raw: true })
const c = chats.map(chat => jsonUtils.chatToJson(chat)); const c = chats.map(chat => jsonUtils.chatToJson(chat));
success(res, c) success(res, c)
} }
async function mute(req, res) { export async function mute(req, res) {
const chatId = req.params['chat_id'] const chatId = req.params['chat_id']
const mute = req.params['mute_unmute'] const mute = req.params['mute_unmute']
@ -73,7 +73,7 @@ async function mute(req, res) {
// just add self here if tribes // just add self here if tribes
// or can u add contacts as members? // or can u add contacts as members?
async function createGroupChat(req, res) { export async function createGroupChat(req, res) {
const { const {
name, name,
is_tribe, is_tribe,
@ -159,7 +159,7 @@ async function createGroupChat(req, res) {
} }
// only owner can do for tribe? // only owner can do for tribe?
async function addGroupMembers(req, res) { export async function addGroupMembers(req, res) {
const { const {
contact_ids, contact_ids,
} = req.body } = req.body
@ -199,7 +199,7 @@ async function addGroupMembers(req, res) {
}) })
} }
const deleteChat = async (req, res) => { export const deleteChat = async (req, res) => {
const { id } = req.params const { id } = req.params
const owner = await models.Contact.findOne({ where: { isOwner: true } }) const owner = await models.Contact.findOne({ where: { isOwner: true } })
@ -234,7 +234,7 @@ const deleteChat = async (req, res) => {
success(res, { chat_id: id }) success(res, { chat_id: id })
} }
async function receiveGroupJoin(payload) { export async function receiveGroupJoin(payload) {
console.log('=> receiveGroupJoin') console.log('=> receiveGroupJoin')
const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner, date_string } = await helpers.parseReceiveParams(payload) const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner, date_string } = await helpers.parseReceiveParams(payload)
@ -323,9 +323,9 @@ async function receiveGroupJoin(payload) {
}) })
} }
async function receiveGroupLeave(payload) { export async function receiveGroupLeave(payload) {
console.log('=> receiveGroupLeave') console.log('=> receiveGroupLeave')
const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner, date_string } = await helpers.parseReceiveParams(payload) const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner, date_string, chat_members } = await helpers.parseReceiveParams(payload)
const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } }) const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if (!chat) return if (!chat) return
@ -333,6 +333,7 @@ async function receiveGroupLeave(payload) {
const isTribe = chat_type===constants.chat_types.tribe const isTribe = chat_type===constants.chat_types.tribe
let sender let sender
// EITHER private chat OR tribeOwner
if(!isTribe || isTribeOwner) { if(!isTribe || isTribeOwner) {
sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } }) sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } })
if (!sender) return if (!sender) return
@ -354,8 +355,39 @@ async function receiveGroupLeave(payload) {
} }
} }
} else { } else {
console.log('==> received leave as subsribers')
// check if im the only one in "members" // check if im the only one in "members"
// and delete chat?? // if im the one in members
// i've been kicked out!
const owner = await models.Contact.findOne({where:{isOwner:true}})
let imKickedOut = false
for (let [pubkey, _] of Object.entries(chat_members)) {
console.log('==> member pubkey', pubkey, owner.publicKey)
if(pubkey===owner.publicKey) {
imKickedOut = true
}
}
if(imKickedOut) {
console.log('==> IM kicked out!')
await chat.update({
deleted: true,
uuid:'',
groupKey:'',
host:'',
photoUrl:'',
contactIds:'[]',
name:''
})
await models.Message.destroy({ where: { chatId: chat.id } })
socket.sendJson({
type: 'group_leave',
response: {
contact: jsonUtils.contactToJson(owner),
chat: jsonUtils.chatToJson(chat),
}
})
return // done - I've been kicked out
}
} }
var date = new Date(); var date = new Date();
@ -394,7 +426,7 @@ async function validateTribeOwner(chat_uuid: string, pubkey: string){
} }
return false return false
} }
async function receiveGroupCreateOrInvite(payload) { export async function receiveGroupCreateOrInvite(payload) {
const { sender_pub_key, chat_members, chat_name, chat_uuid, chat_type, chat_host, chat_key } = await helpers.parseReceiveParams(payload) const { sender_pub_key, chat_members, chat_name, chat_uuid, chat_type, chat_host, chat_key } = await helpers.parseReceiveParams(payload)
// maybe this just needs to move to adding tribe owner ChatMember? // maybe this just needs to move to adding tribe owner ChatMember?
@ -511,12 +543,6 @@ function createGroupChatParams(owner, contactIds, members, name) {
} }
} }
export {
getChats, mute, addGroupMembers, kickChatMember,
receiveGroupCreateOrInvite, createGroupChat,
deleteChat, receiveGroupLeave, receiveGroupJoin,
}
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);

26
api/controllers/contacts.ts

@ -10,7 +10,7 @@ import { Op } from 'sequelize'
const constants = require(path.join(__dirname,'../../config/constants.json')) const constants = require(path.join(__dirname,'../../config/constants.json'))
const getContacts = async (req, res) => { export const getContacts = async (req, res) => {
const contacts = await models.Contact.findAll({ where:{deleted:false}, raw: true }) const contacts = await models.Contact.findAll({ where:{deleted:false}, raw: true })
const invites = await models.Invite.findAll({ raw: true }) const invites = await models.Invite.findAll({ raw: true })
const chats = await models.Chat.findAll({ where:{deleted:false}, raw: true }) const chats = await models.Chat.findAll({ where:{deleted:false}, raw: true })
@ -37,7 +37,7 @@ const getContacts = async (req, res) => {
}) })
} }
const generateToken = async (req, res) => { export const generateToken = async (req, res) => {
console.log('=> generateToken called', { body: req.body, params: req.params, query: req.query }) console.log('=> generateToken called', { body: req.body, params: req.params, query: req.query })
const owner = await models.Contact.findOne({ where: { isOwner: true, authToken: null }}) const owner = await models.Contact.findOne({ where: { isOwner: true, authToken: null }})
@ -66,7 +66,7 @@ const generateToken = async (req, res) => {
} }
} }
const updateContact = async (req, res) => { export const updateContact = async (req, res) => {
console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query }) console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query })
let attrs = extractAttrs(req.body) let attrs = extractAttrs(req.body)
@ -97,7 +97,7 @@ const updateContact = async (req, res) => {
}) })
} }
const exchangeKeys = async (req, res) => { export const exchangeKeys = async (req, res) => {
console.log('=> exchangeKeys called', { body: req.body, params: req.params, query: req.query }) console.log('=> exchangeKeys called', { body: req.body, params: req.params, query: req.query })
const contact = await models.Contact.findOne({ where: { id: req.params.id }}) const contact = await models.Contact.findOne({ where: { id: req.params.id }})
@ -112,7 +112,7 @@ const exchangeKeys = async (req, res) => {
}) })
} }
const createContact = async (req, res) => { export const createContact = async (req, res) => {
console.log('=> createContact called', { body: req.body, params: req.params, query: req.query }) console.log('=> createContact called', { body: req.body, params: req.params, query: req.query })
let attrs = extractAttrs(req.body) let attrs = extractAttrs(req.body)
@ -140,7 +140,7 @@ const createContact = async (req, res) => {
}) })
} }
const deleteContact = async (req, res) => { export const deleteContact = async (req, res) => {
const id = parseInt(req.params.id||'0') const id = parseInt(req.params.id||'0')
if(!id || id===1) { if(!id || id===1) {
failure(res, 'Cannot delete self') failure(res, 'Cannot delete self')
@ -195,7 +195,7 @@ const deleteContact = async (req, res) => {
success(res, {}) success(res, {})
} }
const receiveContactKey = async (payload) => { export const receiveContactKey = async (payload) => {
console.log('=> received contact key', JSON.stringify(payload)) console.log('=> received contact key', JSON.stringify(payload))
const dat = payload.content || payload const dat = payload.content || payload
@ -230,7 +230,7 @@ const receiveContactKey = async (payload) => {
}) })
} }
const receiveConfirmContactKey = async (payload) => { export const receiveConfirmContactKey = async (payload) => {
console.log(`=> confirm contact key for ${payload.sender&&payload.sender.pub_key}`, JSON.stringify(payload)) console.log(`=> confirm contact key for ${payload.sender&&payload.sender.pub_key}`, JSON.stringify(payload))
const dat = payload.content || payload const dat = payload.content || payload
@ -268,13 +268,3 @@ const extractAttrs = body => {
return attrs return attrs
} }
export {
generateToken,
exchangeKeys,
getContacts,
updateContact,
createContact,
deleteContact,
receiveContactKey,
receiveConfirmContactKey
}

21
api/controllers/details.ts

@ -12,7 +12,7 @@ const defaultLogFiles = [
'/home/lnd/.pm2/logs/app-error.log', '/home/lnd/.pm2/logs/app-error.log',
'/var/log/syslog', '/var/log/syslog',
] ]
async function getLogsSince(req, res) { export async function getLogsSince(req, res) {
const logFiles = config.log_file ? [config.log_file] : defaultLogFiles const logFiles = config.log_file ? [config.log_file] : defaultLogFiles
let txt let txt
let err let err
@ -34,7 +34,7 @@ async function getLogsSince(req, res) {
else failure(res, err) else failure(res, err)
} }
const getInfo = async (req, res) => { export const getInfo = async (req, res) => {
const lightning = loadLightning() const lightning = loadLightning()
var request = {} var request = {}
lightning.getInfo(request, function(err, response) { lightning.getInfo(request, function(err, response) {
@ -48,7 +48,7 @@ const getInfo = async (req, res) => {
}); });
}; };
const getChannels = async (req, res) => { export const getChannels = async (req, res) => {
const lightning = loadLightning() const lightning = loadLightning()
var request = {} var request = {}
lightning.listChannels(request, function(err, response) { lightning.listChannels(request, function(err, response) {
@ -62,7 +62,7 @@ const getChannels = async (req, res) => {
}); });
}; };
const getBalance = (req, res) => { export const getBalance = (req, res) => {
const lightning = loadLightning() const lightning = loadLightning()
var request = {} var request = {}
lightning.channelBalance(request, function(err, response) { lightning.channelBalance(request, function(err, response) {
@ -76,7 +76,7 @@ const getBalance = (req, res) => {
}); });
}; };
const getLocalRemoteBalance = async (req, res) => { export const getLocalRemoteBalance = async (req, res) => {
const lightning = loadLightning() const lightning = loadLightning()
lightning.listChannels({}, (err, channelList) => { lightning.listChannels({}, (err, channelList) => {
const { channels } = channelList const { channels } = channelList
@ -96,7 +96,7 @@ const getLocalRemoteBalance = async (req, res) => {
}) })
}; };
const getNodeInfo = async (req, res) => { export const getNodeInfo = async (req, res) => {
var ipOfSource = req.connection.remoteAddress; var ipOfSource = req.connection.remoteAddress;
if(!(ipOfSource.includes('127.0.0.1') || ipOfSource.includes('localhost'))){ if(!(ipOfSource.includes('127.0.0.1') || ipOfSource.includes('localhost'))){
res.status(401) res.status(401)
@ -109,15 +109,6 @@ const getNodeInfo = async (req, res) => {
res.end() res.end()
} }
export {
getInfo,
getBalance,
getChannels,
getLocalRemoteBalance,
getLogsSince,
getNodeInfo,
}
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);

6
api/controllers/index.ts

@ -20,7 +20,7 @@ const env = process.env.NODE_ENV || 'development';
console.log("=> env:",env) console.log("=> env:",env)
const constants = require(path.join(__dirname,'../../config/constants.json')) const constants = require(path.join(__dirname,'../../config/constants.json'))
async function set(app) { export async function set(app) {
if(models && models.Subscription){ if(models && models.Subscription){
subcriptions.initializeCronJobs() subcriptions.initializeCronJobs()
@ -117,7 +117,7 @@ const login = (req, res) => {
} }
const msgtypes = constants.message_types const msgtypes = constants.message_types
const ACTIONS = { export const ACTIONS = {
[msgtypes.contact_key]: contacts.receiveContactKey, [msgtypes.contact_key]: contacts.receiveContactKey,
[msgtypes.contact_key_confirmation]: contacts.receiveConfirmContactKey, [msgtypes.contact_key_confirmation]: contacts.receiveConfirmContactKey,
[msgtypes.message]: messages.receiveMessage, [msgtypes.message]: messages.receiveMessage,
@ -135,5 +135,3 @@ const ACTIONS = {
[msgtypes.delete]: messages.receiveDeleteMessage, [msgtypes.delete]: messages.receiveDeleteMessage,
[msgtypes.repayment]: ()=>{}, [msgtypes.repayment]: ()=>{},
} }
export {set, ACTIONS}

11
api/controllers/invites.ts

@ -3,7 +3,7 @@ import * as crypto from 'crypto'
import * as jsonUtils from '../utils/json' import * as jsonUtils from '../utils/json'
import {finishInviteInHub, createInviteInHub, payInviteInvoice} from '../hub' import {finishInviteInHub, createInviteInHub, payInviteInvoice} from '../hub'
const finishInvite = async (req, res) => { export const finishInvite = async (req, res) => {
const { const {
invite_string invite_string
} = req.body } = req.body
@ -27,7 +27,7 @@ const finishInvite = async (req, res) => {
finishInviteInHub(params, onSuccess, onFailure) finishInviteInHub(params, onSuccess, onFailure)
} }
const payInvite = async (req, res) => { export const payInvite = async (req, res) => {
// const params = { // const params = {
// node_ip: process.env.NODE_IP // node_ip: process.env.NODE_IP
// } // }
@ -62,7 +62,7 @@ const payInvite = async (req, res) => {
payInviteInvoice(dbInvite.invoice, onSuccess, onFailure) payInviteInvoice(dbInvite.invoice, onSuccess, onFailure)
} }
const createInvite = async (req, res) => { export const createInvite = async (req, res) => {
const { const {
nickname, nickname,
welcome_message welcome_message
@ -115,8 +115,3 @@ const createInvite = async (req, res) => {
createInviteInHub(params, onSuccess, onFailure) createInviteInHub(params, onSuccess, onFailure)
} }
export {
createInvite,
finishInvite,
payInvite
}

18
api/controllers/invoices.ts

@ -18,7 +18,7 @@ function stripLightningPrefix(s){
return s return s
} }
const payInvoice = async (req, res) => { export const payInvoice = async (req, res) => {
const lightning = await loadLightning() const lightning = await loadLightning()
const payment_request = stripLightningPrefix(req.body.payment_request) const payment_request = stripLightningPrefix(req.body.payment_request)
@ -75,13 +75,13 @@ const payInvoice = async (req, res) => {
call.write({ payment_request }) call.write({ payment_request })
}; };
const cancelInvoice = (req, res) => { export const cancelInvoice = (req, res) => {
res.status(200); res.status(200);
res.json({ success: false }); res.json({ success: false });
res.end(); res.end();
}; };
const createInvoice = async (req, res) => { export const createInvoice = async (req, res) => {
const lightning = await loadLightning() const lightning = await loadLightning()
const { const {
@ -180,7 +180,7 @@ const createInvoice = async (req, res) => {
} }
}; };
const listInvoices = async (req, res) => { export const listInvoices = async (req, res) => {
const lightning = await loadLightning() const lightning = await loadLightning()
lightning.listInvoices({}, (err, response) => { lightning.listInvoices({}, (err, response) => {
@ -195,7 +195,7 @@ const listInvoices = async (req, res) => {
}); });
}; };
const receiveInvoice = async (payload) => { export const receiveInvoice = async (payload) => {
console.log('received invoice', payload) console.log('received invoice', payload)
const total_spent = 1 const total_spent = 1
@ -246,14 +246,6 @@ const receiveInvoice = async (payload) => {
sendConfirmation({ chat:theChat, sender: owner, msg_id }) sendConfirmation({ chat:theChat, sender: owner, msg_id })
} }
export {
listInvoices,
payInvoice,
cancelInvoice,
createInvoice,
receiveInvoice
}
// lnd invoice stuff // lnd invoice stuff
function decodePaymentRequest(paymentRequest) { function decodePaymentRequest(paymentRequest) {

38
api/controllers/media.ts

@ -39,7 +39,7 @@ purchase_accept should update the original attachment message with the terms and
purchase_deny returns the sats purchase_deny returns the sats
*/ */
const sendAttachmentMessage = async (req, res) => { export const sendAttachmentMessage = async (req, res) => {
// try { // try {
// schemas.attachment.validateSync(req.body) // schemas.attachment.validateSync(req.body)
// } catch(e) { // } catch(e) {
@ -143,7 +143,7 @@ const sendAttachmentMessage = async (req, res) => {
}) })
} }
function saveMediaKeys(muid, mediaKeyMap, chatId, messageId, mediaType){ export function saveMediaKeys(muid, mediaKeyMap, chatId, messageId, mediaType){
if (typeof mediaKeyMap!=='object'){ if (typeof mediaKeyMap!=='object'){
console.log('wrong type for mediaKeyMap') console.log('wrong type for mediaKeyMap')
return return
@ -163,7 +163,7 @@ function saveMediaKeys(muid, mediaKeyMap, chatId, messageId, mediaType){
} }
} }
const purchase = async (req, res) => { export const purchase = async (req, res) => {
const { const {
chat_id, chat_id,
contact_id, contact_id,
@ -218,7 +218,7 @@ const purchase = async (req, res) => {
/* RECEIVERS */ /* RECEIVERS */
const receivePurchase = async (payload) => { export const receivePurchase = async (payload) => {
console.log('=> received purchase', { payload }) console.log('=> received purchase', { payload })
var date = new Date(); var date = new Date();
@ -346,7 +346,7 @@ const receivePurchase = async (payload) => {
}) })
} }
const receivePurchaseAccept = async (payload) => { export const receivePurchaseAccept = async (payload) => {
console.log('=> receivePurchaseAccept') console.log('=> receivePurchaseAccept')
var date = new Date(); var date = new Date();
date.setMilliseconds(0) date.setMilliseconds(0)
@ -391,7 +391,7 @@ const receivePurchaseAccept = async (payload) => {
}) })
} }
const receivePurchaseDeny = async (payload) => { export const receivePurchaseDeny = async (payload) => {
console.log('=> receivePurchaseDeny') console.log('=> receivePurchaseDeny')
var date = new Date() var date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
@ -418,7 +418,7 @@ const receivePurchaseDeny = async (payload) => {
}) })
} }
const receiveAttachment = async (payload) => { export const receiveAttachment = async (payload) => {
// console.log('received attachment', { payload }) // console.log('received attachment', { payload })
var date = new Date(); var date = new Date();
@ -463,7 +463,7 @@ const receiveAttachment = async (payload) => {
sendConfirmation({ chat:theChat, sender: owner, msg_id }) sendConfirmation({ chat:theChat, sender: owner, msg_id })
} }
async function signer(req, res) { export async function signer(req, res) {
if(!req.params.challenge) return resUtils.failure(res, "no challenge") if(!req.params.challenge) return resUtils.failure(res, "no challenge")
try { try {
const sig = await signBuffer( const sig = await signBuffer(
@ -479,7 +479,7 @@ async function signer(req, res) {
} }
} }
async function verifier(msg, sig) { export async function verifier(msg, sig) {
try { try {
const res = await verifyMessage(msg, sig) const res = await verifyMessage(msg, sig)
return res return res
@ -488,7 +488,7 @@ async function verifier(msg, sig) {
} }
} }
async function getMyPubKey(){ export async function getMyPubKey(){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
const lightning = loadLightning() const lightning = loadLightning()
var request = {} var request = {}
@ -500,7 +500,7 @@ async function getMyPubKey(){
}) })
} }
async function cycleMediaToken() { export async function cycleMediaToken() {
try{ try{
if (process.env.TEST_LDAT) testLDAT() if (process.env.TEST_LDAT) testLDAT()
@ -520,7 +520,7 @@ async function cycleMediaToken() {
const mediaURL = 'http://' + config.media_host + '/' const mediaURL = 'http://' + config.media_host + '/'
async function getMediaToken(force) { export async function getMediaToken(force) {
if(!force && meme.mediaToken) return meme.mediaToken if(!force && meme.mediaToken) return meme.mediaToken
await helpers.sleep(3000) await helpers.sleep(3000)
try { try {
@ -556,7 +556,7 @@ async function getMediaToken(force) {
} }
} }
async function getMediaInfo(muid) { export async function getMediaInfo(muid) {
try { try {
const token = await getMediaToken(null) const token = await getMediaToken(null)
const res = await rp.get(mediaURL+'mymedia/'+muid,{ const res = await rp.get(mediaURL+'mymedia/'+muid,{
@ -572,15 +572,3 @@ async function getMediaInfo(muid) {
} }
} }
export {
sendAttachmentMessage,
receiveAttachment,
receivePurchase,
receivePurchaseAccept,
receivePurchaseDeny,
purchase,
signer,
verifier,
getMediaToken,
cycleMediaToken
}

27
api/controllers/messages.ts

@ -14,7 +14,7 @@ import * as short from 'short-uuid'
const constants = require(path.join(__dirname,'../../config/constants.json')) const constants = require(path.join(__dirname,'../../config/constants.json'))
const getMessages = async (req, res) => { export const getMessages = async (req, res) => {
const dateToReturn = req.query.date; const dateToReturn = req.query.date;
if (!dateToReturn) { if (!dateToReturn) {
@ -88,7 +88,7 @@ const getMessages = async (req, res) => {
res.end() res.end()
} }
const getAllMessages = async (req, res) => { export const getAllMessages = async (req, res) => {
const limit = (req.query.limit && parseInt(req.query.limit)) || 1000 const limit = (req.query.limit && parseInt(req.query.limit)) || 1000
const offset = (req.query.offset && parseInt(req.query.offset)) || 0 const offset = (req.query.offset && parseInt(req.query.offset)) || 0
@ -106,7 +106,7 @@ const getAllMessages = async (req, res) => {
}) })
}; };
async function deleteMessage(req, res){ export async function deleteMessage(req, res){
const id = parseInt(req.params.id) const id = parseInt(req.params.id)
const message = await models.Message.findOne({where:{id}}) const message = await models.Message.findOne({where:{id}})
@ -137,7 +137,7 @@ async function deleteMessage(req, res){
}) })
} }
const sendMessage = async (req, res) => { export const sendMessage = async (req, res) => {
// try { // try {
// schemas.message.validateSync(req.body) // schemas.message.validateSync(req.body)
// } catch(e) { // } catch(e) {
@ -198,7 +198,7 @@ const sendMessage = async (req, res) => {
}) })
} }
const receiveMessage = async (payload) => { export const receiveMessage = async (payload) => {
// console.log('received message', { payload }) // console.log('received message', { payload })
var date = new Date(); var date = new Date();
@ -246,7 +246,7 @@ const receiveMessage = async (payload) => {
sendConfirmation({ chat:theChat, sender: owner, msg_id }) sendConfirmation({ chat:theChat, sender: owner, msg_id })
} }
const receiveDeleteMessage = async (payload) => { export const receiveDeleteMessage = async (payload) => {
console.log('=> received delete message') console.log('=> received delete message')
const {owner, sender, chat, chat_type, msg_uuid} = await helpers.parseReceiveParams(payload) const {owner, sender, chat, chat_type, msg_uuid} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) { if(!owner || !sender || !chat) {
@ -269,7 +269,7 @@ const receiveDeleteMessage = async (payload) => {
}) })
} }
const readMessages = async (req, res) => { export const readMessages = async (req, res) => {
const chat_id = req.params.chat_id; const chat_id = req.params.chat_id;
const owner = await models.Contact.findOne({ where: { isOwner: true }}) const owner = await models.Contact.findOne({ where: { isOwner: true }})
@ -286,19 +286,8 @@ const readMessages = async (req, res) => {
success(res, {}) success(res, {})
} }
const clearMessages = (req, res) => { export const clearMessages = (req, res) => {
models.Message.destroy({ where: {}, truncate: true }) models.Message.destroy({ where: {}, truncate: true })
success(res, {}) success(res, {})
} }
export {
getMessages,
sendMessage,
receiveMessage,
clearMessages,
readMessages,
deleteMessage,
getAllMessages,
receiveDeleteMessage,
}

11
api/controllers/payment.ts

@ -10,7 +10,7 @@ import * as constants from '../../config/constants.json'
import * as network from '../network' import * as network from '../network'
import * as short from 'short-uuid' import * as short from 'short-uuid'
const sendPayment = async (req, res) => { export const sendPayment = async (req, res) => {
const { const {
amount, amount,
chat_id, chat_id,
@ -125,7 +125,7 @@ const sendPayment = async (req, res) => {
}) })
}; };
const receivePayment = async (payload) => { export const receivePayment = async (payload) => {
console.log('received payment', { payload }) console.log('received payment', { payload })
var date = new Date(); var date = new Date();
@ -167,7 +167,7 @@ const receivePayment = async (payload) => {
sendNotification(chat, msg.senderAlias||sender.alias, 'message') sendNotification(chat, msg.senderAlias||sender.alias, 'message')
} }
const listPayments = async (req, res) => { export const listPayments = async (req, res) => {
const limit = (req.query.limit && parseInt(req.query.limit)) || 100 const limit = (req.query.limit && parseInt(req.query.limit)) || 100
const offset = (req.query.offset && parseInt(req.query.offset)) || 0 const offset = (req.query.offset && parseInt(req.query.offset)) || 0
@ -217,8 +217,3 @@ const listPayments = async (req, res) => {
success(res, payments.splice(offset, limit)) success(res, payments.splice(offset, limit))
}; };
export {
sendPayment,
receivePayment,
listPayments,
}

12
api/controllers/schemas.ts

@ -5,25 +5,19 @@ These schemas validate payloads coming from app,
do not necessarily match up with Models do not necessarily match up with Models
*/ */
const attachment = yup.object().shape({ export const attachment = yup.object().shape({
muid: yup.string().required(), muid: yup.string().required(),
media_type: yup.string().required(), media_type: yup.string().required(),
media_key_map: yup.object().required(), media_key_map: yup.object().required(),
}) })
const message = yup.object().shape({ export const message = yup.object().shape({
contact_id: yup.number().required(), contact_id: yup.number().required(),
}) })
const purchase = yup.object().shape({ export const purchase = yup.object().shape({
chat_id: yup.number().required(), chat_id: yup.number().required(),
contact_id: yup.number().required(), contact_id: yup.number().required(),
media_token: yup.string().required(), media_token: yup.string().required(),
amount: yup.number().required() amount: yup.number().required()
}) })
export {
attachment,
purchase,
message,
}

29
api/controllers/subscriptions.ts

@ -17,7 +17,7 @@ const constants = require(path.join(__dirname,'../../config/constants.json'))
let jobs = {} let jobs = {}
// init jobs from DB // init jobs from DB
const initializeCronJobs = async () => { export const initializeCronJobs = async () => {
await helpers.sleep(1000) await helpers.sleep(1000)
const subs = await getRawSubs({ where: { ended: false } }) const subs = await getRawSubs({ where: { ended: false } })
subs.length && subs.forEach(sub => { subs.length && subs.forEach(sub => {
@ -189,7 +189,7 @@ async function sendSubscriptionPayment(sub, isFirstMessage) {
} }
// pause sub // pause sub
async function pauseSubscription(req, res) { export async function pauseSubscription(req, res) {
const id = parseInt(req.params.id) const id = parseInt(req.params.id)
try { try {
const sub = await models.Subscription.findOne({ where: { id } }) const sub = await models.Subscription.findOne({ where: { id } })
@ -207,7 +207,7 @@ async function pauseSubscription(req, res) {
}; };
// restart sub // restart sub
async function restartSubscription(req, res) { export async function restartSubscription(req, res) {
const id = parseInt(req.params.id) const id = parseInt(req.params.id)
try { try {
const sub = await models.Subscription.findOne({ where: { id } }) const sub = await models.Subscription.findOne({ where: { id } })
@ -235,7 +235,7 @@ async function getRawSubs(opts = {}) {
} }
// all subs // all subs
const getAllSubscriptions = async (req, res) => { export const getAllSubscriptions = async (req, res) => {
try { try {
const subs = await getRawSubs() const subs = await getRawSubs()
success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub,null))) success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub,null)))
@ -246,7 +246,7 @@ const getAllSubscriptions = async (req, res) => {
}; };
// one sub by id // one sub by id
async function getSubscription(req, res) { export async function getSubscription(req, res) {
try { try {
const sub = await models.Subscription.findOne({ where: { id: req.params.id } }) const sub = await models.Subscription.findOne({ where: { id: req.params.id } })
success(res, jsonUtils.subscriptionToJson(sub,null)) success(res, jsonUtils.subscriptionToJson(sub,null))
@ -257,7 +257,7 @@ async function getSubscription(req, res) {
}; };
// delete sub by id // delete sub by id
async function deleteSubscription(req, res) { export async function deleteSubscription(req, res) {
const id = req.params.id const id = req.params.id
if (!id) return if (!id) return
try { try {
@ -274,7 +274,7 @@ async function deleteSubscription(req, res) {
}; };
// all subs for contact id // all subs for contact id
const getSubscriptionsForContact = async (req, res) => { export const getSubscriptionsForContact = async (req, res) => {
try { try {
const subs = await getRawSubs({ where: { contactId: req.params.contactId } }) const subs = await getRawSubs({ where: { contactId: req.params.contactId } })
success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub,null))) success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub,null)))
@ -285,7 +285,7 @@ const getSubscriptionsForContact = async (req, res) => {
}; };
// create new sub // create new sub
async function createSubscription(req, res) { export async function createSubscription(req, res) {
const date = new Date() const date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
const s = jsonToSubscription({ const s = jsonToSubscription({
@ -321,7 +321,7 @@ async function createSubscription(req, res) {
} }
}; };
async function editSubscription(req, res) { export async function editSubscription(req, res) {
console.log('======> editSubscription') console.log('======> editSubscription')
const date = new Date() const date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
@ -376,14 +376,3 @@ function jsonToSubscription(j) {
}) })
} }
export {
initializeCronJobs,
getAllSubscriptions,
getSubscription,
createSubscription,
getSubscriptionsForContact,
pauseSubscription,
restartSubscription,
deleteSubscription,
editSubscription,
}

9
api/controllers/uploads.ts

@ -22,7 +22,7 @@ var avatarStorage = multer.diskStorage({
} }
} }
}) })
var avatarUpload = multer({ storage: avatarStorage }) export var avatarUpload = multer({ storage: avatarStorage })
function hasProtocol(ip){ function hasProtocol(ip){
if(ip.startsWith('https://')) return true if(ip.startsWith('https://')) return true
@ -30,7 +30,7 @@ function hasProtocol(ip){
return false return false
} }
const uploadFile = async (req, res) => { export const uploadFile = async (req, res) => {
const { contact_id, chat_id } = req.body const { contact_id, chat_id } = req.body
const { file } = req const { file } = req
@ -62,8 +62,3 @@ const uploadFile = async (req, res) => {
}); });
res.end(); res.end();
} }
export {
avatarUpload,
uploadFile
}

5
api/grpc/index.ts

@ -12,7 +12,7 @@ const constants = require(path.join(__dirname,'../../config/constants.json'))
const ERR_CODE_UNAVAILABLE = 14 const ERR_CODE_UNAVAILABLE = 14
const ERR_CODE_STREAM_REMOVED = 2 const ERR_CODE_STREAM_REMOVED = 2
function subscribeInvoices(parseKeysendInvoice) { export function subscribeInvoices(parseKeysendInvoice) {
return new Promise(async(resolve,reject)=>{ return new Promise(async(resolve,reject)=>{
const lightning = await loadLightning() const lightning = await loadLightning()
@ -134,6 +134,3 @@ async function reconnectToLND(innerCtx:number){
} }
} }
export {
subscribeInvoices,
}

24
api/helpers.ts

@ -4,7 +4,7 @@ import * as network from './network'
const constants = require('../config/constants.json'); const constants = require('../config/constants.json');
const findOrCreateChat = async (params) => { export const findOrCreateChat = async (params) => {
const { chat_id, owner_id, recipient_id } = params const { chat_id, owner_id, recipient_id } = params
let chat let chat
let date = new Date(); let date = new Date();
@ -35,7 +35,7 @@ const findOrCreateChat = async (params) => {
return chat return chat
} }
const sendContactKeys = async (args) => { export const sendContactKeys = async (args) => {
const { type, contactIds, contactPubKey, sender, success, failure } = args const { type, contactIds, contactPubKey, sender, success, failure } = args
const msg = newkeyexchangemsg(type, sender) const msg = newkeyexchangemsg(type, sender)
@ -76,7 +76,7 @@ const sendContactKeys = async (args) => {
} }
} }
const performKeysendMessage = async ({ destination_key, amount, msg, success, failure, sender }) => { export const performKeysendMessage = async ({ destination_key, amount, msg, success, failure, sender }) => {
const opts = { const opts = {
dest: destination_key, dest: destination_key,
data: msg || {}, data: msg || {},
@ -92,7 +92,7 @@ const performKeysendMessage = async ({ destination_key, amount, msg, success, fa
} }
} }
async function findOrCreateContactByPubkey(senderPubKey) { export async function findOrCreateContactByPubkey(senderPubKey) {
let sender = await models.Contact.findOne({ where: { publicKey: senderPubKey } }) let sender = await models.Contact.findOne({ where: { publicKey: senderPubKey } })
if (!sender) { if (!sender) {
sender = await models.Contact.create({ sender = await models.Contact.create({
@ -111,7 +111,7 @@ async function findOrCreateContactByPubkey(senderPubKey) {
return sender return sender
} }
async function findOrCreateChatByUUID(chat_uuid, contactIds) { export async function findOrCreateChatByUUID(chat_uuid, contactIds) {
let chat = await models.Chat.findOne({ where: { uuid: chat_uuid } }) let chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if (!chat) { if (!chat) {
var date = new Date(); var date = new Date();
@ -127,11 +127,11 @@ async function findOrCreateChatByUUID(chat_uuid, contactIds) {
return chat return chat
} }
async function sleep(ms) { export async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)) return new Promise(resolve => setTimeout(resolve, ms))
} }
async function parseReceiveParams(payload) { export async function parseReceiveParams(payload) {
const dat = payload.content || payload const dat = payload.content || payload
const sender_pub_key = dat.sender.pub_key const sender_pub_key = dat.sender.pub_key
const sender_alias = dat.sender.alias const sender_alias = dat.sender.alias
@ -180,16 +180,6 @@ async function parseReceiveParams(payload) {
return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, originalMuid, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content, msg_uuid, date_string, reply_uuid, skip_payment_processing, purchaser_id, sender_photo_url } return { owner, sender, chat, sender_pub_key, sender_alias, isTribeOwner, chat_uuid, amount, content, mediaToken, mediaKey, mediaType, originalMuid, chat_type, msg_id, chat_members, chat_name, chat_host, chat_key, remote_content, msg_uuid, date_string, reply_uuid, skip_payment_processing, purchaser_id, sender_photo_url }
} }
export {
findOrCreateChat,
sendContactKeys,
findOrCreateContactByPubkey,
findOrCreateChatByUUID,
sleep,
parseReceiveParams,
performKeysendMessage
}
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);

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

File diff suppressed because one or more lines are too long

39
dist/api/controllers/chats.js

@ -194,7 +194,7 @@ function addGroupMembers(req, res) {
}); });
} }
exports.addGroupMembers = addGroupMembers; exports.addGroupMembers = addGroupMembers;
const deleteChat = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.deleteChat = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { id } = req.params; const { id } = req.params;
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const chat = yield models_1.models.Chat.findOne({ where: { id } }); const chat = yield models_1.models.Chat.findOne({ where: { id } });
@ -223,7 +223,6 @@ const deleteChat = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
yield models_1.models.Message.destroy({ where: { chatId: id } }); yield models_1.models.Message.destroy({ where: { chatId: id } });
res_1.success(res, { chat_id: id }); res_1.success(res, { chat_id: id });
}); });
exports.deleteChat = deleteChat;
function receiveGroupJoin(payload) { function receiveGroupJoin(payload) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupJoin'); console.log('=> receiveGroupJoin');
@ -314,12 +313,13 @@ exports.receiveGroupJoin = receiveGroupJoin;
function receiveGroupLeave(payload) { function receiveGroupLeave(payload) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupLeave'); console.log('=> receiveGroupLeave');
const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner, date_string } = yield helpers.parseReceiveParams(payload); const { sender_pub_key, chat_uuid, chat_type, sender_alias, isTribeOwner, date_string, chat_members } = yield helpers.parseReceiveParams(payload);
const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } }); const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (!chat) if (!chat)
return; return;
const isTribe = chat_type === constants.chat_types.tribe; const isTribe = chat_type === constants.chat_types.tribe;
let sender; let sender;
// EITHER private chat OR tribeOwner
if (!isTribe || isTribeOwner) { if (!isTribe || isTribeOwner) {
sender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pub_key } }); sender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pub_key } });
if (!sender) if (!sender)
@ -342,8 +342,39 @@ function receiveGroupLeave(payload) {
} }
} }
else { else {
console.log('==> received leave as subsribers');
// check if im the only one in "members" // check if im the only one in "members"
// and delete chat?? // if im the one in members
// i've been kicked out!
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
let imKickedOut = false;
for (let [pubkey, _] of Object.entries(chat_members)) {
console.log('==> member pubkey', pubkey, owner.publicKey);
if (pubkey === owner.publicKey) {
imKickedOut = true;
}
}
if (imKickedOut) {
console.log('==> IM kicked out!');
yield chat.update({
deleted: true,
uuid: '',
groupKey: '',
host: '',
photoUrl: '',
contactIds: '[]',
name: ''
});
yield models_1.models.Message.destroy({ where: { chatId: chat.id } });
socket.sendJson({
type: 'group_leave',
response: {
contact: jsonUtils.contactToJson(owner),
chat: jsonUtils.chatToJson(chat),
}
});
return; // done - I've been kicked out
}
} }
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);

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

File diff suppressed because one or more lines are too long

24
dist/api/controllers/contacts.js

@ -19,7 +19,7 @@ const password_1 = require("../utils/password");
const path = require("path"); const path = require("path");
const sequelize_1 = require("sequelize"); const sequelize_1 = require("sequelize");
const constants = require(path.join(__dirname, '../../config/constants.json')); const constants = require(path.join(__dirname, '../../config/constants.json'));
const getContacts = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.getContacts = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const contacts = yield models_1.models.Contact.findAll({ where: { deleted: false }, raw: true }); const contacts = yield models_1.models.Contact.findAll({ where: { deleted: false }, raw: true });
const invites = yield models_1.models.Invite.findAll({ raw: true }); const invites = yield models_1.models.Invite.findAll({ raw: true });
const chats = yield models_1.models.Chat.findAll({ where: { deleted: false }, raw: true }); const chats = yield models_1.models.Chat.findAll({ where: { deleted: false }, raw: true });
@ -40,8 +40,7 @@ const getContacts = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
subscriptions: subsResponse subscriptions: subsResponse
}); });
}); });
exports.getContacts = getContacts; exports.generateToken = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const generateToken = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> generateToken called', { body: req.body, params: req.params, query: req.query }); console.log('=> generateToken called', { body: req.body, params: req.params, query: req.query });
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true, authToken: null } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true, authToken: null } });
const pwd = password_1.default; const pwd = password_1.default;
@ -65,8 +64,7 @@ const generateToken = (req, res) => __awaiter(void 0, void 0, void 0, function*
res_1.failure(res, {}); res_1.failure(res, {});
} }
}); });
exports.generateToken = generateToken; exports.updateContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const updateContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query }); console.log('=> updateContact called', { body: req.body, params: req.params, query: req.query });
let attrs = extractAttrs(req.body); let attrs = extractAttrs(req.body);
const contact = yield models_1.models.Contact.findOne({ where: { id: req.params.id } }); const contact = yield models_1.models.Contact.findOne({ where: { id: req.params.id } });
@ -89,8 +87,7 @@ const updateContact = (req, res) => __awaiter(void 0, void 0, void 0, function*
type: constants.message_types.contact_key, type: constants.message_types.contact_key,
}); });
}); });
exports.updateContact = updateContact; exports.exchangeKeys = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const exchangeKeys = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> exchangeKeys called', { body: req.body, params: req.params, query: req.query }); console.log('=> exchangeKeys called', { body: req.body, params: req.params, query: req.query });
const contact = yield models_1.models.Contact.findOne({ where: { id: req.params.id } }); const contact = yield models_1.models.Contact.findOne({ where: { id: req.params.id } });
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
@ -101,8 +98,7 @@ const exchangeKeys = (req, res) => __awaiter(void 0, void 0, void 0, function* (
type: constants.message_types.contact_key, type: constants.message_types.contact_key,
}); });
}); });
exports.exchangeKeys = exchangeKeys; exports.createContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const createContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> createContact called', { body: req.body, params: req.params, query: req.query }); console.log('=> createContact called', { body: req.body, params: req.params, query: req.query });
let attrs = extractAttrs(req.body); let attrs = extractAttrs(req.body);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
@ -125,8 +121,7 @@ const createContact = (req, res) => __awaiter(void 0, void 0, void 0, function*
type: constants.message_types.contact_key, type: constants.message_types.contact_key,
}); });
}); });
exports.createContact = createContact; exports.deleteContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const deleteContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const id = parseInt(req.params.id || '0'); const id = parseInt(req.params.id || '0');
if (!id || id === 1) { if (!id || id === 1) {
res_1.failure(res, 'Cannot delete self'); res_1.failure(res, 'Cannot delete self');
@ -176,8 +171,7 @@ const deleteContact = (req, res) => __awaiter(void 0, void 0, void 0, function*
yield models_1.models.Subscription.destroy({ where: { contactId: id } }); yield models_1.models.Subscription.destroy({ where: { contactId: id } });
res_1.success(res, {}); res_1.success(res, {});
}); });
exports.deleteContact = deleteContact; exports.receiveContactKey = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receiveContactKey = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> received contact key', JSON.stringify(payload)); console.log('=> received contact key', JSON.stringify(payload));
const dat = payload.content || payload; const dat = payload.content || payload;
const sender_pub_key = dat.sender.pub_key; const sender_pub_key = dat.sender.pub_key;
@ -207,8 +201,7 @@ const receiveContactKey = (payload) => __awaiter(void 0, void 0, void 0, functio
type: constants.message_types.contact_key_confirmation, type: constants.message_types.contact_key_confirmation,
}); });
}); });
exports.receiveContactKey = receiveContactKey; exports.receiveConfirmContactKey = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receiveConfirmContactKey = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log(`=> confirm contact key for ${payload.sender && payload.sender.pub_key}`, JSON.stringify(payload)); console.log(`=> confirm contact key for ${payload.sender && payload.sender.pub_key}`, JSON.stringify(payload));
const dat = payload.content || payload; const dat = payload.content || payload;
const sender_pub_key = dat.sender.pub_key; const sender_pub_key = dat.sender.pub_key;
@ -232,7 +225,6 @@ const receiveConfirmContactKey = (payload) => __awaiter(void 0, void 0, void 0,
}); });
} }
}); });
exports.receiveConfirmContactKey = receiveConfirmContactKey;
const extractAttrs = body => { const extractAttrs = body => {
let fields_to_update = ["public_key", "node_alias", "alias", "photo_url", "device_id", "status", "contact_key", "from_group", "private_photo"]; let fields_to_update = ["public_key", "node_alias", "alias", "photo_url", "device_id", "status", "contact_key", "from_group", "private_photo"];
let attrs = {}; let attrs = {};

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

File diff suppressed because one or more lines are too long

15
dist/api/controllers/details.js

@ -48,7 +48,7 @@ function getLogsSince(req, res) {
}); });
} }
exports.getLogsSince = getLogsSince; exports.getLogsSince = getLogsSince;
const getInfo = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.getInfo = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const lightning = lightning_1.loadLightning(); const lightning = lightning_1.loadLightning();
var request = {}; var request = {};
lightning.getInfo(request, function (err, response) { lightning.getInfo(request, function (err, response) {
@ -62,8 +62,7 @@ const getInfo = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
res.end(); res.end();
}); });
}); });
exports.getInfo = getInfo; exports.getChannels = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const getChannels = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const lightning = lightning_1.loadLightning(); const lightning = lightning_1.loadLightning();
var request = {}; var request = {};
lightning.listChannels(request, function (err, response) { lightning.listChannels(request, function (err, response) {
@ -77,8 +76,7 @@ const getChannels = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
res.end(); res.end();
}); });
}); });
exports.getChannels = getChannels; exports.getBalance = (req, res) => {
const getBalance = (req, res) => {
const lightning = lightning_1.loadLightning(); const lightning = lightning_1.loadLightning();
var request = {}; var request = {};
lightning.channelBalance(request, function (err, response) { lightning.channelBalance(request, function (err, response) {
@ -92,8 +90,7 @@ const getBalance = (req, res) => {
res.end(); res.end();
}); });
}; };
exports.getBalance = getBalance; exports.getLocalRemoteBalance = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const getLocalRemoteBalance = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const lightning = lightning_1.loadLightning(); const lightning = lightning_1.loadLightning();
lightning.listChannels({}, (err, channelList) => { lightning.listChannels({}, (err, channelList) => {
const { channels } = channelList; const { channels } = channelList;
@ -111,8 +108,7 @@ const getLocalRemoteBalance = (req, res) => __awaiter(void 0, void 0, void 0, fu
res.end(); res.end();
}); });
}); });
exports.getLocalRemoteBalance = getLocalRemoteBalance; exports.getNodeInfo = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const getNodeInfo = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
var ipOfSource = req.connection.remoteAddress; var ipOfSource = req.connection.remoteAddress;
if (!(ipOfSource.includes('127.0.0.1') || ipOfSource.includes('localhost'))) { if (!(ipOfSource.includes('127.0.0.1') || ipOfSource.includes('localhost'))) {
res.status(401); res.status(401);
@ -124,7 +120,6 @@ const getNodeInfo = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
res.json(node); res.json(node);
res.end(); res.end();
}); });
exports.getNodeInfo = getNodeInfo;
function asyncForEach(array, callback) { function asyncForEach(array, callback) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {

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

@ -1 +1 @@
{"version":3,"file":"details.js","sourceRoot":"","sources":["../../../api/controllers/details.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAAgD;AAChD,sCAA+C;AAC/C,iDAAgD;AAChD,gDAA6C;AAC7C,6BAA4B;AAE5B,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,MAAM,eAAe,GAAG;IACvB,+BAA+B;IAC/B,mCAAmC;IACnC,iBAAiB;CACjB,CAAA;AACD,SAAe,YAAY,CAAC,GAAG,EAAE,GAAG;;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,eAAe,CAAA;QACtE,IAAI,GAAG,CAAA;QACP,IAAI,GAAG,CAAA;QACP,MAAM,YAAY,CAAC,QAAQ,EAAE,CAAM,QAAQ,EAAA,EAAE;YAC5C,IAAG,CAAC,GAAG,EAAC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AC,MAAM,CAAC,GAAG,CAAC,CAAA;QACf,GAAG,CAAC,GAAG,EAAE,CAAA;QACT,OAAM;KACN;IACD,MAAM,IAAI,GAAG,MAAM,mBAAQ,EAAE,CAAA;IAC7B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACf,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,GAAG,CAAC,GAAG,EAAE,CAAA;AACV,CAAC,CAAA,CAAA;AAED,SAAe,YAAY,CAAC,KAAK,EAAE,QAAQ;;QAC1C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAChD,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC7C;IACF,CAAC;CAAA"}

3
dist/api/controllers/index.js

@ -115,7 +115,7 @@ const login = (req, res) => {
} }
}; };
const msgtypes = constants.message_types; const msgtypes = constants.message_types;
const ACTIONS = { exports.ACTIONS = {
[msgtypes.contact_key]: contacts.receiveContactKey, [msgtypes.contact_key]: contacts.receiveContactKey,
[msgtypes.contact_key_confirmation]: contacts.receiveConfirmContactKey, [msgtypes.contact_key_confirmation]: contacts.receiveConfirmContactKey,
[msgtypes.message]: messages.receiveMessage, [msgtypes.message]: messages.receiveMessage,
@ -133,5 +133,4 @@ const ACTIONS = {
[msgtypes.delete]: messages.receiveDeleteMessage, [msgtypes.delete]: messages.receiveDeleteMessage,
[msgtypes.repayment]: () => { }, [msgtypes.repayment]: () => { },
}; };
exports.ACTIONS = ACTIONS;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

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

File diff suppressed because one or more lines are too long

9
dist/api/controllers/invites.js

@ -13,7 +13,7 @@ const models_1 = require("../models");
const crypto = require("crypto"); const crypto = require("crypto");
const jsonUtils = require("../utils/json"); const jsonUtils = require("../utils/json");
const hub_1 = require("../hub"); const hub_1 = require("../hub");
const finishInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.finishInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { invite_string } = req.body; const { invite_string } = req.body;
const params = { const params = {
invite: { invite: {
@ -32,8 +32,7 @@ const finishInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* (
} }
hub_1.finishInviteInHub(params, onSuccess, onFailure); hub_1.finishInviteInHub(params, onSuccess, onFailure);
}); });
exports.finishInvite = finishInvite; exports.payInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const payInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
// const params = { // const params = {
// node_ip: process.env.NODE_IP // node_ip: process.env.NODE_IP
// } // }
@ -64,8 +63,7 @@ const payInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
// payInviteInHub(invite_string, params, onSuccess, onFailure) // payInviteInHub(invite_string, params, onSuccess, onFailure)
hub_1.payInviteInvoice(dbInvite.invoice, onSuccess, onFailure); hub_1.payInviteInvoice(dbInvite.invoice, onSuccess, onFailure);
}); });
exports.payInvite = payInvite; exports.createInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const createInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { nickname, welcome_message } = req.body; const { nickname, welcome_message } = req.body;
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const params = { const params = {
@ -105,5 +103,4 @@ const createInvite = (req, res) => __awaiter(void 0, void 0, void 0, function* (
}; };
hub_1.createInviteInHub(params, onSuccess, onFailure); hub_1.createInviteInHub(params, onSuccess, onFailure);
}); });
exports.createInvite = createInvite;
//# sourceMappingURL=invites.js.map //# sourceMappingURL=invites.js.map

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

@ -1 +1 @@
{"version":3,"file":"invites.js","sourceRoot":"","sources":["../../../api/controllers/invites.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAgC;AAChC,iCA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,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AACnD,CAAC,CAAA,CAAA"}

15
dist/api/controllers/invoices.js

@ -27,7 +27,7 @@ function stripLightningPrefix(s) {
return s.substring(10); return s.substring(10);
return s; return s;
} }
const payInvoice = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.payInvoice = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const lightning = yield lightning_1.loadLightning(); const lightning = yield lightning_1.loadLightning();
const payment_request = stripLightningPrefix(req.body.payment_request); const payment_request = stripLightningPrefix(req.body.payment_request);
if (!payment_request) { if (!payment_request) {
@ -74,14 +74,12 @@ const payInvoice = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
})); }));
call.write({ payment_request }); call.write({ payment_request });
}); });
exports.payInvoice = payInvoice; exports.cancelInvoice = (req, res) => {
const cancelInvoice = (req, res) => {
res.status(200); res.status(200);
res.json({ success: false }); res.json({ success: false });
res.end(); res.end();
}; };
exports.cancelInvoice = cancelInvoice; exports.createInvoice = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const createInvoice = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const lightning = yield lightning_1.loadLightning(); const lightning = yield lightning_1.loadLightning();
const { amount, memo, remote_memo, chat_id, contact_id, expiry, } = req.body; const { amount, memo, remote_memo, chat_id, contact_id, expiry, } = req.body;
var request = { var request = {
@ -166,8 +164,7 @@ const createInvoice = (req, res) => __awaiter(void 0, void 0, void 0, function*
}); });
} }
}); });
exports.createInvoice = createInvoice; exports.listInvoices = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const listInvoices = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const lightning = yield lightning_1.loadLightning(); const lightning = yield lightning_1.loadLightning();
lightning.listInvoices({}, (err, response) => { lightning.listInvoices({}, (err, response) => {
console.log({ err, response }); console.log({ err, response });
@ -181,8 +178,7 @@ const listInvoices = (req, res) => __awaiter(void 0, void 0, void 0, function* (
} }
}); });
}); });
exports.listInvoices = listInvoices; exports.receiveInvoice = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receiveInvoice = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('received invoice', payload); console.log('received invoice', payload);
const total_spent = 1; const total_spent = 1;
const dat = payload.content || payload; const dat = payload.content || payload;
@ -225,7 +221,6 @@ const receiveInvoice = (payload) => __awaiter(void 0, void 0, void 0, function*
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] }); const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] });
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id }); confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
}); });
exports.receiveInvoice = receiveInvoice;
// lnd invoice stuff // lnd invoice stuff
function decodePaymentRequest(paymentRequest) { function decodePaymentRequest(paymentRequest) {
var decodedPaymentRequest = decodeUtils.decode(paymentRequest); var decodedPaymentRequest = decodeUtils.decode(paymentRequest);

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

File diff suppressed because one or more lines are too long

21
dist/api/controllers/media.js

@ -47,7 +47,7 @@ purchase_accept should update the original attachment message with the terms and
purchase_deny returns the sats purchase_deny returns the sats
*/ */
const sendAttachmentMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.sendAttachmentMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
// try { // try {
// schemas.attachment.validateSync(req.body) // schemas.attachment.validateSync(req.body)
// } catch(e) { // } catch(e) {
@ -130,7 +130,6 @@ const sendAttachmentMessage = (req, res) => __awaiter(void 0, void 0, void 0, fu
failure: error => resUtils.failure(res, error.message), failure: error => resUtils.failure(res, error.message),
}); });
}); });
exports.sendAttachmentMessage = sendAttachmentMessage;
function saveMediaKeys(muid, mediaKeyMap, chatId, messageId, mediaType) { function saveMediaKeys(muid, mediaKeyMap, chatId, messageId, mediaType) {
if (typeof mediaKeyMap !== 'object') { if (typeof mediaKeyMap !== 'object') {
console.log('wrong type for mediaKeyMap'); console.log('wrong type for mediaKeyMap');
@ -150,7 +149,8 @@ function saveMediaKeys(muid, mediaKeyMap, chatId, messageId, mediaType) {
} }
} }
} }
const purchase = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.saveMediaKeys = saveMediaKeys;
exports.purchase = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { chat_id, contact_id, amount, media_token, } = req.body; const { chat_id, contact_id, amount, media_token, } = req.body;
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -194,9 +194,8 @@ const purchase = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
failure: error => resUtils.failure(res, error.message), failure: error => resUtils.failure(res, error.message),
}); });
}); });
exports.purchase = purchase;
/* RECEIVERS */ /* RECEIVERS */
const receivePurchase = (payload) => __awaiter(void 0, void 0, void 0, function* () { exports.receivePurchase = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> received purchase', { payload }); console.log('=> received purchase', { payload });
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -316,8 +315,7 @@ const receivePurchase = (payload) => __awaiter(void 0, void 0, void 0, function*
failure: error => console.log('=> couldnt send purchase accept', error), failure: error => console.log('=> couldnt send purchase accept', error),
}); });
}); });
exports.receivePurchase = receivePurchase; exports.receivePurchaseAccept = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receivePurchaseAccept = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> receivePurchaseAccept'); console.log('=> receivePurchaseAccept');
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -358,8 +356,7 @@ const receivePurchaseAccept = (payload) => __awaiter(void 0, void 0, void 0, fun
response: jsonUtils.messageToJson(msg, chat, sender) response: jsonUtils.messageToJson(msg, chat, sender)
}); });
}); });
exports.receivePurchaseAccept = receivePurchaseAccept; exports.receivePurchaseDeny = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receivePurchaseDeny = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> receivePurchaseDeny'); console.log('=> receivePurchaseDeny');
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -385,8 +382,7 @@ const receivePurchaseDeny = (payload) => __awaiter(void 0, void 0, void 0, funct
response: jsonUtils.messageToJson(msg, chat, sender) response: jsonUtils.messageToJson(msg, chat, sender)
}); });
}); });
exports.receivePurchaseDeny = receivePurchaseDeny; exports.receiveAttachment = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receiveAttachment = (payload) => __awaiter(void 0, void 0, void 0, function* () {
// console.log('received attachment', { payload }) // console.log('received attachment', { payload })
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -427,7 +423,6 @@ const receiveAttachment = (payload) => __awaiter(void 0, void 0, void 0, functio
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] }); const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] });
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id }); confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
}); });
exports.receiveAttachment = receiveAttachment;
function signer(req, res) { function signer(req, res) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!req.params.challenge) if (!req.params.challenge)
@ -474,6 +469,7 @@ function getMyPubKey() {
}); });
}); });
} }
exports.getMyPubKey = getMyPubKey;
function cycleMediaToken() { function cycleMediaToken() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@ -549,4 +545,5 @@ function getMediaInfo(muid) {
} }
}); });
} }
exports.getMediaInfo = getMediaInfo;
//# sourceMappingURL=media.js.map //# sourceMappingURL=media.js.map

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

File diff suppressed because one or more lines are too long

23
dist/api/controllers/messages.js

@ -23,10 +23,10 @@ const path = require("path");
const network = require("../network"); const network = require("../network");
const short = require("short-uuid"); const short = require("short-uuid");
const constants = require(path.join(__dirname, '../../config/constants.json')); const constants = require(path.join(__dirname, '../../config/constants.json'));
const getMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.getMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const dateToReturn = req.query.date; const dateToReturn = req.query.date;
if (!dateToReturn) { if (!dateToReturn) {
return getAllMessages(req, res); return exports.getAllMessages(req, res);
} }
console.log(dateToReturn); console.log(dateToReturn);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
@ -84,8 +84,7 @@ const getMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
res.status(200); res.status(200);
res.end(); res.end();
}); });
exports.getMessages = getMessages; exports.getAllMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const getAllMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const limit = (req.query.limit && parseInt(req.query.limit)) || 1000; const limit = (req.query.limit && parseInt(req.query.limit)) || 1000;
const offset = (req.query.offset && parseInt(req.query.offset)) || 0; const offset = (req.query.offset && parseInt(req.query.offset)) || 0;
const messages = yield models_1.models.Message.findAll({ order: [['id', 'asc']], limit, offset }); const messages = yield models_1.models.Message.findAll({ order: [['id', 'asc']], limit, offset });
@ -98,7 +97,6 @@ const getAllMessages = (req, res) => __awaiter(void 0, void 0, void 0, function*
confirmed_messages: [] confirmed_messages: []
}); });
}); });
exports.getAllMessages = getAllMessages;
function deleteMessage(req, res) { function deleteMessage(req, res) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const id = parseInt(req.params.id); const id = parseInt(req.params.id);
@ -128,7 +126,7 @@ function deleteMessage(req, res) {
}); });
} }
exports.deleteMessage = deleteMessage; exports.deleteMessage = deleteMessage;
const sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
// try { // try {
// schemas.message.validateSync(req.body) // schemas.message.validateSync(req.body)
// } catch(e) { // } catch(e) {
@ -177,8 +175,7 @@ const sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
message: msgToSend, message: msgToSend,
}); });
}); });
exports.sendMessage = sendMessage; exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
// console.log('received message', { payload }) // console.log('received message', { payload })
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -220,8 +217,7 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] }); const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] });
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id }); confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
}); });
exports.receiveMessage = receiveMessage; exports.receiveDeleteMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receiveDeleteMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> received delete message'); console.log('=> received delete message');
const { owner, sender, chat, chat_type, msg_uuid } = yield helpers.parseReceiveParams(payload); const { owner, sender, chat, chat_type, msg_uuid } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) { if (!owner || !sender || !chat) {
@ -242,8 +238,7 @@ const receiveDeleteMessage = (payload) => __awaiter(void 0, void 0, void 0, func
response: jsonUtils.messageToJson(message, chat, sender) response: jsonUtils.messageToJson(message, chat, sender)
}); });
}); });
exports.receiveDeleteMessage = receiveDeleteMessage; exports.readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const chat_id = req.params.chat_id; const chat_id = req.params.chat_id;
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
models_1.models.Message.update({ seen: true }, { models_1.models.Message.update({ seen: true }, {
@ -256,10 +251,8 @@ const readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* (
}); });
res_1.success(res, {}); res_1.success(res, {});
}); });
exports.readMessages = readMessages; exports.clearMessages = (req, res) => {
const clearMessages = (req, res) => {
models_1.models.Message.destroy({ where: {}, truncate: true }); models_1.models.Message.destroy({ where: {}, truncate: true });
res_1.success(res, {}); res_1.success(res, {});
}; };
exports.clearMessages = clearMessages;
//# sourceMappingURL=messages.js.map //# sourceMappingURL=messages.js.map

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

File diff suppressed because one or more lines are too long

9
dist/api/controllers/payment.js

@ -20,7 +20,7 @@ const ldat_1 = require("../utils/ldat");
const constants = require("../../config/constants.json"); const constants = require("../../config/constants.json");
const network = require("../network"); const network = require("../network");
const short = require("short-uuid"); const short = require("short-uuid");
const sendPayment = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.sendPayment = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { amount, chat_id, contact_id, destination_key, media_type, muid, text, remote_text, dimensions, remote_text_map, contact_ids, reply_uuid, } = req.body; const { amount, chat_id, contact_id, destination_key, media_type, muid, text, remote_text, dimensions, remote_text_map, contact_ids, reply_uuid, } = req.body;
console.log('[send payment]', req.body); console.log('[send payment]', req.body);
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
@ -117,8 +117,7 @@ const sendPayment = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
}) })
}); });
}); });
exports.sendPayment = sendPayment; exports.receivePayment = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const receivePayment = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('received payment', { payload }); console.log('received payment', { payload });
var date = new Date(); var date = new Date();
date.setMilliseconds(0); date.setMilliseconds(0);
@ -156,8 +155,7 @@ const receivePayment = (payload) => __awaiter(void 0, void 0, void 0, function*
}); });
hub_1.sendNotification(chat, msg.senderAlias || sender.alias, 'message'); hub_1.sendNotification(chat, msg.senderAlias || sender.alias, 'message');
}); });
exports.receivePayment = receivePayment; exports.listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const limit = (req.query.limit && parseInt(req.query.limit)) || 100; const limit = (req.query.limit && parseInt(req.query.limit)) || 100;
const offset = (req.query.offset && parseInt(req.query.offset)) || 0; const offset = (req.query.offset && parseInt(req.query.offset)) || 0;
const payments = []; const payments = [];
@ -200,5 +198,4 @@ const listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* (
payments.sort((a, b) => b.date - a.date); payments.sort((a, b) => b.date - a.date);
res_1.success(res, payments.splice(offset, limit)); res_1.success(res, payments.splice(offset, limit));
}); });
exports.listPayments = listPayments;
//# sourceMappingURL=payment.js.map //# sourceMappingURL=payment.js.map

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

File diff suppressed because one or more lines are too long

9
dist/api/controllers/schemas.js

@ -5,21 +5,18 @@ const yup = require("yup");
These schemas validate payloads coming from app, These schemas validate payloads coming from app,
do not necessarily match up with Models do not necessarily match up with Models
*/ */
const attachment = yup.object().shape({ exports.attachment = yup.object().shape({
muid: yup.string().required(), muid: yup.string().required(),
media_type: yup.string().required(), media_type: yup.string().required(),
media_key_map: yup.object().required(), media_key_map: yup.object().required(),
}); });
exports.attachment = attachment; exports.message = yup.object().shape({
const message = yup.object().shape({
contact_id: yup.number().required(), contact_id: yup.number().required(),
}); });
exports.message = message; exports.purchase = yup.object().shape({
const purchase = yup.object().shape({
chat_id: yup.number().required(), chat_id: yup.number().required(),
contact_id: yup.number().required(), contact_id: yup.number().required(),
media_token: yup.string().required(), media_token: yup.string().required(),
amount: yup.number().required() amount: yup.number().required()
}); });
exports.purchase = purchase;
//# sourceMappingURL=schemas.js.map //# sourceMappingURL=schemas.js.map

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

@ -1 +1 @@
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../api/controllers/schemas.ts"],"names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AAC,MAAM,EAAE,CAAC,KAAK,CAAC;IACtC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA;AAEW,QAAA,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC;IACvC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAA"}

9
dist/api/controllers/subscriptions.js

@ -25,7 +25,7 @@ const constants = require(path.join(__dirname, '../../config/constants.json'));
// store all current running jobs in memory // store all current running jobs in memory
let jobs = {}; let jobs = {};
// init jobs from DB // init jobs from DB
const initializeCronJobs = () => __awaiter(void 0, void 0, void 0, function* () { exports.initializeCronJobs = () => __awaiter(void 0, void 0, void 0, function* () {
yield helpers.sleep(1000); yield helpers.sleep(1000);
const subs = yield getRawSubs({ where: { ended: false } }); const subs = yield getRawSubs({ where: { ended: false } });
subs.length && subs.forEach(sub => { subs.length && subs.forEach(sub => {
@ -33,7 +33,6 @@ const initializeCronJobs = () => __awaiter(void 0, void 0, void 0, function* ()
startCronJob(sub); startCronJob(sub);
}); });
}); });
exports.initializeCronJobs = initializeCronJobs;
function startCronJob(sub) { function startCronJob(sub) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
jobs[sub.id] = new cron_1.CronJob(sub.cron, function () { jobs[sub.id] = new cron_1.CronJob(sub.cron, function () {
@ -254,7 +253,7 @@ function getRawSubs(opts = {}) {
}); });
} }
// all subs // all subs
const getAllSubscriptions = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.getAllSubscriptions = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
try { try {
const subs = yield getRawSubs(); const subs = yield getRawSubs();
res_1.success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub, null))); res_1.success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub, null)));
@ -264,7 +263,6 @@ const getAllSubscriptions = (req, res) => __awaiter(void 0, void 0, void 0, func
res_1.failure(res, e); res_1.failure(res, e);
} }
}); });
exports.getAllSubscriptions = getAllSubscriptions;
// one sub by id // one sub by id
function getSubscription(req, res) { function getSubscription(req, res) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -303,7 +301,7 @@ function deleteSubscription(req, res) {
exports.deleteSubscription = deleteSubscription; exports.deleteSubscription = deleteSubscription;
; ;
// all subs for contact id // all subs for contact id
const getSubscriptionsForContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.getSubscriptionsForContact = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
try { try {
const subs = yield getRawSubs({ where: { contactId: req.params.contactId } }); const subs = yield getRawSubs({ where: { contactId: req.params.contactId } });
res_1.success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub, null))); res_1.success(res, subs.map(sub => jsonUtils.subscriptionToJson(sub, null)));
@ -313,7 +311,6 @@ const getSubscriptionsForContact = (req, res) => __awaiter(void 0, void 0, void
res_1.failure(res, e); res_1.failure(res, e);
} }
}); });
exports.getSubscriptionsForContact = getSubscriptionsForContact;
// create new sub // create new sub
function createSubscription(req, res) { function createSubscription(req, res) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {

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

File diff suppressed because one or more lines are too long

6
dist/api/controllers/uploads.js

@ -32,8 +32,7 @@ var avatarStorage = multer.diskStorage({
} }
} }
}); });
var avatarUpload = multer({ storage: avatarStorage }); exports.avatarUpload = multer({ storage: avatarStorage });
exports.avatarUpload = avatarUpload;
function hasProtocol(ip) { function hasProtocol(ip) {
if (ip.startsWith('https://')) if (ip.startsWith('https://'))
return true; return true;
@ -41,7 +40,7 @@ function hasProtocol(ip) {
return true; return true;
return false; return false;
} }
const uploadFile = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.uploadFile = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { contact_id, chat_id } = req.body; const { contact_id, chat_id } = req.body;
const { file } = req; const { file } = req;
const ip = String(process.env.NODE_IP); const ip = String(process.env.NODE_IP);
@ -71,5 +70,4 @@ const uploadFile = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
}); });
res.end(); res.end();
}); });
exports.uploadFile = uploadFile;
//# sourceMappingURL=uploads.js.map //# sourceMappingURL=uploads.js.map

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

@ -1 +1 @@
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../../../api/controllers/uploads.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAgC;AAChC,6BAA4B;AAE5B,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,qBAAqB;AACrB,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC9B,IAAI,aAAa,GAAG,MAAM,CAAC,WAAW,CAAC;IACrC,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;QAC7B,IAAI,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAC9E,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,uBAAuB,CAAC,CAAA;IACzC,CAAC;IACD,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;QAC1B,MAAM,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Q,CAAC,CAAA;iBAC9B;YACF,CAAC,CAAA,EAAC,IAAI,CAAC,CAAA;SACP;IACF,CAAC;CAAA"}

13
dist/api/helpers.js

@ -13,7 +13,7 @@ const models_1 = require("./models");
const md5 = require("md5"); const md5 = require("md5");
const network = require("./network"); const network = require("./network");
const constants = require('../config/constants.json'); const constants = require('../config/constants.json');
const findOrCreateChat = (params) => __awaiter(void 0, void 0, void 0, function* () { exports.findOrCreateChat = (params) => __awaiter(void 0, void 0, void 0, function* () {
const { chat_id, owner_id, recipient_id } = params; const { chat_id, owner_id, recipient_id } = params;
let chat; let chat;
let date = new Date(); let date = new Date();
@ -41,8 +41,7 @@ const findOrCreateChat = (params) => __awaiter(void 0, void 0, void 0, function*
} }
return chat; return chat;
}); });
exports.findOrCreateChat = findOrCreateChat; exports.sendContactKeys = (args) => __awaiter(void 0, void 0, void 0, function* () {
const sendContactKeys = (args) => __awaiter(void 0, void 0, void 0, function* () {
const { type, contactIds, contactPubKey, sender, success, failure } = args; const { type, contactIds, contactPubKey, sender, success, failure } = args;
const msg = newkeyexchangemsg(type, sender); const msg = newkeyexchangemsg(type, sender);
let yes = null; let yes = null;
@ -62,7 +61,7 @@ const sendContactKeys = (args) => __awaiter(void 0, void 0, void 0, function* ()
const contact = yield models_1.models.Contact.findOne({ where: { id: contactId } }); const contact = yield models_1.models.Contact.findOne({ where: { id: contactId } });
destination_key = contact.publicKey; destination_key = contact.publicKey;
} }
performKeysendMessage({ exports.performKeysendMessage({
sender, sender,
destination_key, destination_key,
amount: 3, amount: 3,
@ -82,8 +81,7 @@ const sendContactKeys = (args) => __awaiter(void 0, void 0, void 0, function* ()
success(yes); success(yes);
} }
}); });
exports.sendContactKeys = sendContactKeys; exports.performKeysendMessage = ({ destination_key, amount, msg, success, failure, sender }) => __awaiter(void 0, void 0, void 0, function* () {
const performKeysendMessage = ({ destination_key, amount, msg, success, failure, sender }) => __awaiter(void 0, void 0, void 0, function* () {
const opts = { const opts = {
dest: destination_key, dest: destination_key,
data: msg || {}, data: msg || {},
@ -101,7 +99,6 @@ const performKeysendMessage = ({ destination_key, amount, msg, success, failure,
failure(e); failure(e);
} }
}); });
exports.performKeysendMessage = performKeysendMessage;
function findOrCreateContactByPubkey(senderPubKey) { function findOrCreateContactByPubkey(senderPubKey) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let sender = yield models_1.models.Contact.findOne({ where: { publicKey: senderPubKey } }); let sender = yield models_1.models.Contact.findOne({ where: { publicKey: senderPubKey } });
@ -112,7 +109,7 @@ function findOrCreateContactByPubkey(senderPubKey) {
status: 1 status: 1
}); });
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
sendContactKeys({ exports.sendContactKeys({
contactIds: [sender.id], contactIds: [sender.id],
sender: owner, sender: owner,
type: constants.message_types.contact_key, type: constants.message_types.contact_key,

2
dist/api/helpers.js.map

File diff suppressed because one or more lines are too long

11
dist/public/index.html

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>React app</title>
</head>
<body>
<div id="app"></div>
<script src="/static/js/app.js"></script>
<link href="/static/semantic.min.css" rel="stylesheet" />
</body>
</html>

86159
dist/public/js/app.js

File diff suppressed because one or more lines are too long

BIN
dist/public/relay.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 KiB

372
dist/public/semantic.min.css

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