Browse Source

Merge pull request #89 from stakwork/fixparse

Fixparse
loopout2 v1.0.5
Evan Feenstra 4 years ago
committed by GitHub
parent
commit
76906460eb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dist/src/controllers/confirmations.js
  2. 2
      dist/src/controllers/confirmations.js.map
  3. 8
      dist/src/network/receive.js
  4. 2
      dist/src/network/receive.js.map
  5. 9
      dist/src/utils/res.js
  6. 2
      dist/src/utils/res.js.map
  7. 8
      src/controllers/confirmations.ts
  8. 8
      src/network/receive.ts
  9. 11
      src/utils/res.ts

6
dist/src/controllers/confirmations.js

@ -150,7 +150,7 @@ function healthcheck(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const pubkey = req.query.pubkey;
if (!(pubkey && pubkey.length === 66)) {
return res_1.failure(res, 'missing pubkey');
return res_1.failure200(res, 'missing pubkey');
}
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const amt = 10;
@ -169,7 +169,7 @@ function healthcheck(req, res) {
yield network.signAndSend(opts);
}
catch (e) {
res_1.failure(res, e);
res_1.failure200(res, e);
return;
}
let i = 0;
@ -177,7 +177,7 @@ function healthcheck(req, res) {
if (i >= 15) {
clearInterval(interval);
delete heartbeats[pubkey];
res_1.failure(res, 'no confimration received');
res_1.failure200(res, 'no confimration received');
return;
}
if (heartbeats[pubkey]) {

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

File diff suppressed because one or more lines are too long

8
dist/src/network/receive.js

@ -324,20 +324,20 @@ function parseKeysendInvoice(i) {
if (data) {
try {
const payload = parsePayload(data);
if (payload.type === constants_1.default.message_types.keysend) {
if (payload && payload.type === constants_1.default.message_types.keysend) {
isAnonymous = true;
memo = payload.message.content;
}
}
catch (e) {
isAnonymous = true;
}
catch (e) { } // err could be a threaded TLV
}
else {
isAnonymous = true;
}
if (isAnonymous) {
if (!memo) {
hub_1.sendNotification(-1, '', 'keysend', value || 0);
}
saveAnonymousKeysend(i, memo);
return;
}

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

File diff suppressed because one or more lines are too long

9
dist/src/utils/res.js

@ -18,4 +18,13 @@ function failure(res, e) {
res.end();
}
exports.failure = failure;
function failure200(res, e) {
res.status(200);
res.json({
success: false,
error: (e && e.message) || e,
});
res.end();
}
exports.failure200 = failure200;
//# sourceMappingURL=res.js.map

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

@ -1 +1 @@
{"version":3,"file":"res.js","sourceRoot":"","sources":["../../../src/utils/res.ts"],"names":[],"mappings":";;AAAA,SAAS,OAAO,CAAC,GAAG,EAAE,IAAI;IACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,CAAC;QACP,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAWO,0BAAO;AATf,SAAS,OAAO,CAAC,GAAG,EAAE,CAAC;IACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,CAAC;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,CAAC,CAAC,IAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAEgB,0BAAO"}
{"version":3,"file":"res.js","sourceRoot":"","sources":["../../../src/utils/res.ts"],"names":[],"mappings":";;AAAA,SAAS,OAAO,CAAC,GAAG,EAAE,IAAI;IACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,CAAC;QACP,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAoBO,0BAAO;AAlBf,SAAS,OAAO,CAAC,GAAG,EAAE,CAAC;IACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,CAAC;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,CAAC,CAAC,IAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAWgB,0BAAO;AATxB,SAAS,UAAU,CAAC,GAAG,EAAE,CAAC;IACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,CAAC;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,CAAC,CAAC,IAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAEyB,gCAAU"}

8
src/controllers/confirmations.ts

@ -4,7 +4,7 @@ import * as socket from '../utils/socket'
import * as jsonUtils from '../utils/json'
import * as network from '../network'
import constants from '../constants'
import { failure, success } from '../utils/res'
import { success, failure200 } from '../utils/res'
export function sendConfirmation({ chat, sender, msg_id }) {
if (!msg_id) return
@ -135,7 +135,7 @@ let heartbeats:{[k:string]:boolean} = {}
export async function healthcheck(req, res) {
const pubkey: string = req.query.pubkey
if (!(pubkey && pubkey.length === 66)) {
return failure(res, 'missing pubkey')
return failure200(res, 'missing pubkey')
}
const owner = await models.Contact.findOne({ where: { isOwner: true } })
@ -155,7 +155,7 @@ export async function healthcheck(req, res) {
try {
await network.signAndSend(opts)
} catch (e) {
failure(res, e)
failure200(res, e)
return
}
@ -164,7 +164,7 @@ export async function healthcheck(req, res) {
if (i >= 15) {
clearInterval(interval)
delete heartbeats[pubkey]
failure(res, 'no confimration received')
failure200(res, 'no confimration received')
return
}
if (heartbeats[pubkey]) {

8
src/network/receive.ts

@ -296,18 +296,18 @@ export async function parseKeysendInvoice(i){
if(data){
try {
const payload = parsePayload(data)
if(payload.type===constants.message_types.keysend) {
if(payload && payload.type===constants.message_types.keysend) {
isAnonymous = true
memo = payload.message.content
}
} catch(e) {
isAnonymous = true
}
} catch(e) {} // err could be a threaded TLV
} else {
isAnonymous = true
}
if(isAnonymous) {
if(!memo) {
sendNotification(-1, '', 'keysend', value||0)
}
saveAnonymousKeysend(i, memo)
return
}

11
src/utils/res.ts

@ -16,4 +16,13 @@ function failure(res, e) {
res.end();
}
export {success, failure}
function failure200(res, e) {
res.status(200);
res.json({
success: false,
error: (e&&e.message) || e,
});
res.end();
}
export {success, failure, failure200}
Loading…
Cancel
Save