Browse Source

store escrow repayment msgs and return in list tx

dependabot/npm_and_yarn/ini-1.3.7
Evan Feenstra 4 years ago
parent
commit
298e31c920
  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. 1
      dist/src/controllers/payment.js
  6. 2
      dist/src/controllers/payment.js.map
  7. 2
      src/controllers/index.ts
  8. 29
      src/controllers/messages.ts
  9. 1
      src/controllers/payment.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, chat, 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

1
dist/src/controllers/payment.js

@ -172,6 +172,7 @@ exports.listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function*
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

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

File diff suppressed because one or more lines are too long

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, chat, sender)
})
}
export const receiveDeleteMessage = async (payload) => {
console.log('=> received delete message')
const {owner, sender, chat, chat_type, msg_uuid} = await helpers.parseReceiveParams(payload)

1
src/controllers/payment.ts

@ -188,6 +188,7 @@ export const listPayments = async (req, res) => {
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

Loading…
Cancel
Save