Browse Source

dont inc msg type in history, parse sender_pubkey for keysend type if you have the contact

dependabot/npm_and_yarn/ini-1.3.7
Evan Feenstra 4 years ago
parent
commit
312b524339
  1. 8
      dist/src/controllers/messages.js
  2. 2
      dist/src/controllers/messages.js.map
  3. 8
      dist/src/controllers/payment.js
  4. 2
      dist/src/controllers/payment.js.map
  5. 23
      dist/src/network/receive.js
  6. 2
      dist/src/network/receive.js.map
  7. 10
      dist/src/utils/setup.js
  8. 2
      dist/src/utils/setup.js.map
  9. 8
      src/controllers/messages.ts
  10. 14
      src/controllers/payment.ts
  11. 23
      src/network/receive.ts
  12. 11
      src/utils/setup.ts

8
dist/src/controllers/messages.js

@ -187,7 +187,7 @@ exports.sendMessage = (req, res) => __awaiter(void 0, void 0, void 0, function*
}); });
exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () { exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
// console.log('received message', { payload }) // console.log('received message', { payload })
const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid, amount } = yield helpers.parseReceiveParams(payload); const { owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) { if (!owner || !sender || !chat) {
return console.log('=> no group chat!'); return console.log('=> no group chat!');
} }
@ -202,7 +202,7 @@ exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function
type: constants_1.default.message_types.message, type: constants_1.default.message_types.message,
sender: sender.id, sender: sender.id,
date: date, date: date,
amount: amount || 0, // amount: amount||0,
messageContent: text, messageContent: text,
createdAt: date, createdAt: date,
updatedAt: date, updatedAt: date,
@ -227,7 +227,7 @@ exports.receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function
}); });
exports.receiveBoost = (payload) => __awaiter(void 0, void 0, void 0, function* () { exports.receiveBoost = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('received boost', { payload }); console.log('received boost', { payload });
const { owner, sender, chat, content, remote_content, chat_type, sender_alias, msg_uuid, date_string, reply_uuid, amount } = yield helpers.parseReceiveParams(payload); const { owner, sender, chat, content, remote_content, chat_type, sender_alias, msg_uuid, date_string, reply_uuid } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) { if (!owner || !sender || !chat) {
return console.log('=> no group chat!'); return console.log('=> no group chat!');
} }
@ -242,7 +242,7 @@ exports.receiveBoost = (payload) => __awaiter(void 0, void 0, void 0, function*
type: constants_1.default.message_types.boost, type: constants_1.default.message_types.boost,
sender: sender.id, sender: sender.id,
date: date, date: date,
amount: amount || 0, // amount: amount||0,
messageContent: text, messageContent: text,
createdAt: date, createdAt: date,
updatedAt: date, updatedAt: date,

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

File diff suppressed because one or more lines are too long

8
dist/src/controllers/payment.js

@ -152,7 +152,7 @@ exports.receivePayment = (payload) => __awaiter(void 0, void 0, void 0, function
exports.listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* () { exports.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 MIN_VAL = constants_1.default.min_sat_amount; // const MIN_VAL=constants.min_sat_amount
try { try {
const msgs = yield models_1.models.Message.findAll({ const msgs = yield models_1.models.Message.findAll({
where: { where: {
@ -164,12 +164,6 @@ exports.listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function*
constants_1.default.message_types.keysend, constants_1.default.message_types.keysend,
] } ] }
}, },
{
type: constants_1.default.message_types.message,
amount: {
[sequelize_1.Op.gt]: MIN_VAL // greater than
}
}
], ],
}, },
order: [['createdAt', 'desc']], order: [['createdAt', 'desc']],

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

File diff suppressed because one or more lines are too long

23
dist/src/network/receive.js

@ -316,14 +316,21 @@ function parseAndVerifyPayload(data) {
} }
}); });
} }
function saveAnonymousKeysend(response, memo) { function saveAnonymousKeysend(response, memo, sender_pubkey) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let sender = 0;
if (sender_pubkey) {
const theSender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pubkey } });
if (theSender && theSender.id) {
sender = theSender.id;
}
}
let settleDate = parseInt(response['settle_date'] + '000'); let settleDate = parseInt(response['settle_date'] + '000');
const amount = response['amt_paid_sat'] || 0; const amount = response['amt_paid_sat'] || 0;
const msg = yield models_1.models.Message.create({ const msg = yield models_1.models.Message.create({
chatId: 0, chatId: 0,
type: constants_1.default.message_types.keysend, type: constants_1.default.message_types.keysend,
sender: 0, sender,
amount, amount,
amountMsat: response['amt_paid_msat'], amountMsat: response['amt_paid_msat'],
paymentHash: '', paymentHash: '',
@ -347,26 +354,28 @@ function parseKeysendInvoice(i) {
const value = i && i.value && parseInt(i.value); const value = i && i.value && parseInt(i.value);
// "keysend" type is NOT encrypted // "keysend" type is NOT encrypted
// and should be saved even if there is NO content // and should be saved even if there is NO content
let isAnonymous = false; let isKeysendType = false;
let memo = ''; let memo = '';
let sender_pubkey;
if (data) { if (data) {
try { try {
const payload = parsePayload(data); const payload = parsePayload(data);
if (payload && payload.type === constants_1.default.message_types.keysend) { if (payload && payload.type === constants_1.default.message_types.keysend) {
isAnonymous = true; isKeysendType = true;
memo = payload.message && payload.message.content; memo = payload.message && payload.message.content;
sender_pubkey = payload.sender && payload.sender.pub_key;
} }
} }
catch (e) { } // err could be a threaded TLV catch (e) { } // err could be a threaded TLV
} }
else { else {
isAnonymous = true; isKeysendType = true;
} }
if (isAnonymous) { if (isKeysendType) {
if (!memo) { if (!memo) {
hub_1.sendNotification(-1, '', 'keysend', value || 0); hub_1.sendNotification(-1, '', 'keysend', value || 0);
} }
saveAnonymousKeysend(i, memo); saveAnonymousKeysend(i, memo, sender_pubkey);
return; return;
} }
let payload; let payload;

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

File diff suppressed because one or more lines are too long

10
dist/src/utils/setup.js

@ -204,9 +204,6 @@ function printGitInfo() {
} }
function printQR() { function printQR() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const clean = yield nodeinfo_1.isClean();
if (!clean)
return; // skip it if already setup!
let public_ip; let public_ip;
const public_url = config.public_url; const public_url = config.public_url;
if (public_url) if (public_url)
@ -230,9 +227,12 @@ function printQR() {
let theIP = public_ip; let theIP = public_ip;
// if(!theIP.includes(":")) theIP = public_ip+':3001' // if(!theIP.includes(":")) theIP = public_ip+':3001'
const b64 = Buffer.from(`ip::${theIP}::${password_1.default || ''}`).toString('base64'); const b64 = Buffer.from(`ip::${theIP}::${password_1.default || ''}`).toString('base64');
console.log('Scan this QR in Sphinx app:'); console.log('>>', b64);
console.log(b64);
connectionStringFile(b64); connectionStringFile(b64);
const clean = yield nodeinfo_1.isClean();
if (!clean)
return; // skip it if already setup!
console.log('Scan this QR in Sphinx app:');
QRCode.toString(b64, { type: 'terminal' }, function (err, url) { QRCode.toString(b64, { type: 'terminal' }, function (err, url) {
console.log(url); console.log(url);
}); });

2
dist/src/utils/setup.js.map

File diff suppressed because one or more lines are too long

8
src/controllers/messages.ts

@ -211,7 +211,7 @@ export const sendMessage = async (req, res) => {
export const receiveMessage = async (payload) => { export const receiveMessage = async (payload) => {
// console.log('received message', { payload }) // console.log('received message', { payload })
const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid, amount} = await helpers.parseReceiveParams(payload) const {owner, sender, chat, content, remote_content, msg_id, chat_type, sender_alias, msg_uuid, date_string, reply_uuid} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) { if(!owner || !sender || !chat) {
return console.log('=> no group chat!') return console.log('=> no group chat!')
} }
@ -227,7 +227,7 @@ export const receiveMessage = async (payload) => {
type: constants.message_types.message, type: constants.message_types.message,
sender: sender.id, sender: sender.id,
date: date, date: date,
amount: amount||0, // amount: amount||0,
messageContent: text, messageContent: text,
createdAt: date, createdAt: date,
updatedAt: date, updatedAt: date,
@ -255,7 +255,7 @@ export const receiveMessage = async (payload) => {
export const receiveBoost = async (payload) => { export const receiveBoost = async (payload) => {
console.log('received boost', { payload }) console.log('received boost', { payload })
const {owner, sender, chat, content, remote_content, chat_type, sender_alias, msg_uuid, date_string, reply_uuid, amount} = await helpers.parseReceiveParams(payload) const {owner, sender, chat, content, remote_content, chat_type, sender_alias, msg_uuid, date_string, reply_uuid} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) { if(!owner || !sender || !chat) {
return console.log('=> no group chat!') return console.log('=> no group chat!')
} }
@ -271,7 +271,7 @@ export const receiveBoost = async (payload) => {
type: constants.message_types.boost, type: constants.message_types.boost,
sender: sender.id, sender: sender.id,
date: date, date: date,
amount: amount||0, // amount: amount||0,
messageContent: text, messageContent: text,
createdAt: date, createdAt: date,
updatedAt: date, updatedAt: date,

14
src/controllers/payment.ts

@ -168,7 +168,7 @@ 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
const MIN_VAL=constants.min_sat_amount // const MIN_VAL=constants.min_sat_amount
try { try {
const msgs = await models.Message.findAll({ const msgs = await models.Message.findAll({
where:{ where:{
@ -180,12 +180,12 @@ export const listPayments = async (req, res) => {
constants.message_types.keysend, constants.message_types.keysend,
]} ]}
}, },
{ // {
type: constants.message_types.message, // for example /loopout message // type: constants.message_types.message, // for example /loopout message
amount: { // amount: {
[Op.gt]: MIN_VAL // greater than // [Op.gt]: MIN_VAL // greater than
} // }
} // }
], ],
}, },
order: [['createdAt', 'desc']], order: [['createdAt', 'desc']],

23
src/network/receive.ts

@ -288,13 +288,20 @@ async function parseAndVerifyPayload(data){
} }
} }
async function saveAnonymousKeysend(response, memo) { async function saveAnonymousKeysend(response, memo, sender_pubkey) {
let sender = 0
if(sender_pubkey) {
const theSender = await models.Contact.findOne({ where: { publicKey: sender_pubkey }})
if(theSender && theSender.id) {
sender = theSender.id
}
}
let settleDate = parseInt(response['settle_date'] + '000'); let settleDate = parseInt(response['settle_date'] + '000');
const amount = response['amt_paid_sat'] || 0 const amount = response['amt_paid_sat'] || 0
const msg = await models.Message.create({ const msg = await models.Message.create({
chatId: 0, chatId: 0,
type: constants.message_types.keysend, type: constants.message_types.keysend,
sender: 0, sender,
amount, amount,
amountMsat: response['amt_paid_msat'], amountMsat: response['amt_paid_msat'],
paymentHash: '', paymentHash: '',
@ -318,24 +325,26 @@ export async function parseKeysendInvoice(i){
// "keysend" type is NOT encrypted // "keysend" type is NOT encrypted
// and should be saved even if there is NO content // and should be saved even if there is NO content
let isAnonymous = false let isKeysendType = false
let memo = '' let memo = ''
let sender_pubkey;
if(data){ if(data){
try { try {
const payload = parsePayload(data) const payload = parsePayload(data)
if(payload && payload.type===constants.message_types.keysend) { if(payload && payload.type===constants.message_types.keysend) {
isAnonymous = true isKeysendType = true
memo = payload.message && payload.message.content memo = payload.message && payload.message.content
sender_pubkey = payload.sender && payload.sender.pub_key
} }
} catch(e) {} // err could be a threaded TLV } catch(e) {} // err could be a threaded TLV
} else { } else {
isAnonymous = true isKeysendType = true
} }
if(isAnonymous) { if(isKeysendType) {
if(!memo) { if(!memo) {
sendNotification(-1, '', 'keysend', value||0) sendNotification(-1, '', 'keysend', value||0)
} }
saveAnonymousKeysend(i, memo) saveAnonymousKeysend(i, memo, sender_pubkey)
return return
} }

11
src/utils/setup.ts

@ -203,9 +203,6 @@ async function printGitInfo() {
async function printQR() { async function printQR() {
const clean = await isClean()
if(!clean) return // skip it if already setup!
let public_ip let public_ip
const public_url = config.public_url const public_url = config.public_url
@ -229,9 +226,13 @@ async function printQR() {
// if(!theIP.includes(":")) theIP = public_ip+':3001' // if(!theIP.includes(":")) theIP = public_ip+':3001'
const b64 = Buffer.from(`ip::${theIP}::${password || ''}`).toString('base64') const b64 = Buffer.from(`ip::${theIP}::${password || ''}`).toString('base64')
console.log('Scan this QR in Sphinx app:') console.log('>>', b64)
console.log(b64)
connectionStringFile(b64) connectionStringFile(b64)
const clean = await isClean()
if(!clean) return // skip it if already setup!
console.log('Scan this QR in Sphinx app:')
QRCode.toString(b64, { type: 'terminal' }, function (err, url) { QRCode.toString(b64, { type: 'terminal' }, function (err, url) {
console.log(url) console.log(url)
}) })

Loading…
Cancel
Save