Browse Source

fix msg format

loopout2
Evan Feenstra 4 years ago
parent
commit
75c53ebbd9
  1. 17
      dist/src/network/receive.js
  2. 2
      dist/src/network/receive.js.map
  3. 17
      src/network/receive.ts

17
dist/src/network/receive.js

@ -24,6 +24,7 @@ const timers = require("../utils/timers");
const socket = require("../utils/socket"); const socket = require("../utils/socket");
const hub_1 = require("../hub"); const hub_1 = require("../hub");
const constants_1 = require("../constants"); const constants_1 = require("../constants");
const jsonUtils = require("../utils/json");
/* /*
delete type: delete type:
owner needs to check that the delete is the one who made the msg owner needs to check that the delete is the one who made the msg
@ -290,11 +291,12 @@ function parseAndVerifyPayload(data) {
function saveAnonymousKeysend(response, memo) { function saveAnonymousKeysend(response, memo) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let settleDate = parseInt(response['settle_date'] + '000'); let settleDate = parseInt(response['settle_date'] + '000');
yield models_1.models.Message.create({ const amount = response['amt_paid_sat'] || 0;
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: 0,
amount: response['amt_paid_sat'], amount,
amountMsat: response['amt_paid_msat'], amountMsat: response['amt_paid_msat'],
paymentHash: '', paymentHash: '',
date: new Date(settleDate), date: new Date(settleDate),
@ -303,6 +305,10 @@ function saveAnonymousKeysend(response, memo) {
createdAt: new Date(settleDate), createdAt: new Date(settleDate),
updatedAt: new Date(settleDate) updatedAt: new Date(settleDate)
}); });
socket.sendJson({
type: 'keysend',
response: jsonUtils.messageToJson(msg, null)
});
}); });
} }
function parseKeysendInvoice(i) { function parseKeysendInvoice(i) {
@ -331,13 +337,6 @@ function parseKeysendInvoice(i) {
isAnonymous = true; isAnonymous = true;
} }
if (isAnonymous) { if (isAnonymous) {
socket.sendJson({
type: 'keysend',
response: {
amount: value || 0,
message_content: memo
}
});
hub_1.sendNotification(-1, '', 'keysend', value || 0); hub_1.sendNotification(-1, '', 'keysend', value || 0);
saveAnonymousKeysend(i, memo); saveAnonymousKeysend(i, memo);
return; return;

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

File diff suppressed because one or more lines are too long

17
src/network/receive.ts

@ -13,6 +13,7 @@ import * as timers from '../utils/timers'
import * as socket from '../utils/socket' import * as socket from '../utils/socket'
import { sendNotification } from '../hub' import { sendNotification } from '../hub'
import constants from '../constants' import constants from '../constants'
import * as jsonUtils from '../utils/json'
/* /*
delete type: delete type:
@ -262,11 +263,12 @@ async function parseAndVerifyPayload(data){
async function saveAnonymousKeysend(response, memo) { async function saveAnonymousKeysend(response, memo) {
let settleDate = parseInt(response['settle_date'] + '000'); let settleDate = parseInt(response['settle_date'] + '000');
await models.Message.create({ const amount = response['amt_paid_sat'] || 0
const msg = await models.Message.create({
chatId: 0, chatId: 0,
type: constants.message_types.keysend, type: constants.message_types.keysend,
sender: 0, sender: 0,
amount: response['amt_paid_sat'], amount,
amountMsat: response['amt_paid_msat'], amountMsat: response['amt_paid_msat'],
paymentHash: '', paymentHash: '',
date: new Date(settleDate), date: new Date(settleDate),
@ -275,6 +277,10 @@ async function saveAnonymousKeysend(response, memo) {
createdAt: new Date(settleDate), createdAt: new Date(settleDate),
updatedAt: new Date(settleDate) updatedAt: new Date(settleDate)
}) })
socket.sendJson({
type:'keysend',
response: jsonUtils.messageToJson(msg,null)
})
} }
export async function parseKeysendInvoice(i){ export async function parseKeysendInvoice(i){
@ -301,13 +307,6 @@ export async function parseKeysendInvoice(i){
isAnonymous = true isAnonymous = true
} }
if(isAnonymous) { if(isAnonymous) {
socket.sendJson({
type:'keysend',
response: {
amount:value||0,
message_content:memo
}
})
sendNotification(-1, '', 'keysend', value||0) sendNotification(-1, '', 'keysend', value||0)
saveAnonymousKeysend(i, memo) saveAnonymousKeysend(i, memo)
return return

Loading…
Cancel
Save