Browse Source

Merge pull request #114 from stakwork/fixrepay

Fixrepay
dependabot/npm_and_yarn/ini-1.3.7 v1.1.2
Evan Feenstra 4 years ago
committed by GitHub
parent
commit
db2bd8c838
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dist/src/controllers/index.js
  2. 2
      dist/src/controllers/index.js.map
  3. 26
      dist/src/controllers/messages.js
  4. 2
      dist/src/controllers/messages.js.map
  5. 7
      dist/src/controllers/payment.js
  6. 2
      dist/src/controllers/payment.js.map
  7. 1
      dist/src/utils/timers.js
  8. 2
      dist/src/utils/timers.js.map
  9. 2
      src/controllers/index.ts
  10. 29
      src/controllers/messages.ts
  11. 7
      src/controllers/payment.ts
  12. 1
      src/utils/timers.ts

2
dist/src/controllers/index.js

@ -140,7 +140,7 @@ exports.ACTIONS = {
[msgtypes.group_leave]: chats.receiveGroupLeave,
[msgtypes.group_kick]: chats.receiveGroupKick,
[msgtypes.delete]: messages.receiveDeleteMessage,
[msgtypes.repayment]: () => { },
[msgtypes.repayment]: messages.receiveRepayment,
[msgtypes.member_request]: chatTribes.receiveMemberRequest,
[msgtypes.member_approve]: chatTribes.receiveMemberApprove,
[msgtypes.member_reject]: chatTribes.receiveMemberReject,

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

File diff suppressed because one or more lines are too long

26
dist/src/controllers/messages.js

@ -294,6 +294,32 @@ exports.receiveBoost = (payload) => __awaiter(void 0, void 0, void 0, function*
response: jsonUtils.messageToJson(message, chat, sender)
});
});
exports.receiveRepayment = (payload) => __awaiter(void 0, void 0, void 0, function* () {
const { owner, sender, chat, date_string, amount, network_type } = yield helpers.parseReceiveParams(payload);
console.log('=> received repayment ' + amount + ' sats');
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
var date = new Date();
date.setMilliseconds(0);
if (date_string)
date = new Date(date_string);
const message = yield models_1.models.Message.create({
// chatId: chat.id,
type: constants_1.default.message_types.repayment,
sender: sender.id,
date: date,
amount: amount || 0,
createdAt: date,
updatedAt: date,
status: constants_1.default.statuses.received,
network_type
});
socket.sendJson({
type: 'repayment',
response: jsonUtils.messageToJson(message, null, sender)
});
});
exports.receiveDeleteMessage = (payload) => __awaiter(void 0, void 0, void 0, function* () {
console.log('=> received delete message');
const { owner, sender, chat, chat_type, msg_uuid } = yield helpers.parseReceiveParams(payload);

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

File diff suppressed because one or more lines are too long

7
dist/src/controllers/payment.js

@ -165,17 +165,20 @@ exports.listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function*
constants_1.default.message_types.direct_payment,
constants_1.default.message_types.keysend,
constants_1.default.message_types.purchase,
] }
] },
status: { [sequelize_1.Op.not]: constants_1.default.statuses.failed }
},
{
type: { [sequelize_1.Op.or]: [
constants_1.default.message_types.message,
constants_1.default.message_types.boost,
constants_1.default.message_types.repayment,
] },
amount: {
[sequelize_1.Op.gt]: MIN_VAL // greater than
},
network_type: constants_1.default.network_types.lightning
network_type: constants_1.default.network_types.lightning,
status: { [sequelize_1.Op.not]: constants_1.default.statuses.failed }
}
],
},

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

File diff suppressed because one or more lines are too long

1
dist/src/utils/timers.js

@ -100,6 +100,7 @@ function payBack(t) {
message: { id: t.msgId, amount: t.amount },
amount: t.amount,
type: constants_1.default.message_types.repayment,
realSatsContactId: t.receiver
});
models_1.models.Timer.destroy({ where: { id: t.id } });
});

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

@ -1 +1 @@
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../../../src/utils/timers.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAkC;AAClC,sCAAqC;AACrC,4CAAoC;AAEpC,MAAM,MAAM,GAAC,EAAE,CAAA;AACf,SAAS,UAAU,CAAC,CAAC;IACjB,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACxB,IAAG,IAAI;QAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AACvC,CAAC;AACD,SAAsB,kBAAkB,CAAC,KAAK;;Q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AC,WAAW,CAAC;YAChB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAC,EAAE,EAAC,CAAC,CAAC,KAAK,EAAC,MAAM,EAAC,CAAC,CAAC,MAAM,EAAC;YACrC,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,IAAI,EAAE,mBAAS,CAAC,aAAa,CAAC,SAAS;YACvC,iBAAiB,EAAE,CAAC,CAAC,QAAQ;SAChC,CAAC,CAAA;QACF,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC,EAAC,EAAE,EAAC,CAAC,CAAC,EAAE,EAAC,EAAC,CAAC,CAAA;IAC3C,CAAC;CAAA;AAjBD,0BAiBC"}

2
src/controllers/index.ts

@ -141,7 +141,7 @@ export const ACTIONS = {
[msgtypes.group_leave]: chats.receiveGroupLeave,
[msgtypes.group_kick]: chats.receiveGroupKick,
[msgtypes.delete]: messages.receiveDeleteMessage,
[msgtypes.repayment]: ()=>{},
[msgtypes.repayment]: messages.receiveRepayment,
[msgtypes.member_request]: chatTribes.receiveMemberRequest,
[msgtypes.member_approve]: chatTribes.receiveMemberApprove,
[msgtypes.member_reject]: chatTribes.receiveMemberReject,

29
src/controllers/messages.ts

@ -325,6 +325,35 @@ export const receiveBoost = async (payload) => {
})
}
export const receiveRepayment = async (payload) => {
const {owner, sender, chat, date_string, amount, network_type} = await helpers.parseReceiveParams(payload)
console.log('=> received repayment ' +amount+ ' sats')
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
var date = new Date();
date.setMilliseconds(0)
if(date_string) date=new Date(date_string)
const message = await models.Message.create({
// chatId: chat.id,
type: constants.message_types.repayment,
sender: sender.id,
date: date,
amount: amount||0,
createdAt: date,
updatedAt: date,
status: constants.statuses.received,
network_type
})
socket.sendJson({
type: 'repayment',
response: jsonUtils.messageToJson(message, null, sender)
})
}
export const receiveDeleteMessage = async (payload) => {
console.log('=> received delete message')
const {owner, sender, chat, chat_type, msg_uuid} = await helpers.parseReceiveParams(payload)

7
src/controllers/payment.ts

@ -181,17 +181,20 @@ export const listPayments = async (req, res) => {
constants.message_types.direct_payment,
constants.message_types.keysend,
constants.message_types.purchase,
]}
]},
status: {[Op.not]: constants.statuses.failed}
},
{
type: {[Op.or]: [
constants.message_types.message, // paid bot msgs, or price_per_message msgs
constants.message_types.boost,
constants.message_types.repayment,
]},
amount: {
[Op.gt]: MIN_VAL // greater than
},
network_type: constants.network_types.lightning
network_type: constants.network_types.lightning,
status: {[Op.not]: constants.statuses.failed}
}
],
},

1
src/utils/timers.ts

@ -72,6 +72,7 @@ export async function payBack(t){
message: {id:t.msgId,amount:t.amount},
amount: t.amount,
type: constants.message_types.repayment,
realSatsContactId: t.receiver
})
models.Timer.destroy({where:{id:t.id}})
}

Loading…
Cancel
Save