Browse Source

sender alias in all msg types, notify, check price val

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
4b782c2a67
  1. 4
      api/controllers/chats.ts
  2. 13
      api/controllers/invoices.ts
  3. 8
      api/controllers/media.ts
  4. 2
      api/controllers/messages.ts
  5. 7
      api/controllers/payment.ts
  6. 2
      dist/api/controllers/chats.js
  7. 2
      dist/api/controllers/chats.js.map
  8. 13
      dist/api/controllers/invoices.js
  9. 2
      dist/api/controllers/invoices.js.map
  10. 8
      dist/api/controllers/media.js
  11. 2
      dist/api/controllers/media.js.map
  12. 2
      dist/api/controllers/messages.js
  13. 2
      dist/api/controllers/messages.js.map
  14. 7
      dist/api/controllers/payment.js
  15. 2
      dist/api/controllers/payment.js.map

4
api/controllers/chats.ts

@ -102,8 +102,8 @@ async function createGroupChat(req, res) {
// publish to tribe server
tribes.declare({
...chatParams,
pricePerMessage: price_per_message,
priceToJoin: price_to_join,
pricePerMessage: price_per_message||0,
priceToJoin: price_to_join||0,
description, tags, img,
})
}

13
api/controllers/invoices.ts

@ -189,14 +189,14 @@ const receiveInvoice = async (payload) => {
var date = new Date();
date.setMilliseconds(0)
const { owner, sender, chat, msg_id } = await helpers.parseReceiveParams(payload)
const { owner, sender, chat, msg_id, chat_type, sender_alias } = await helpers.parseReceiveParams(payload)
if (!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
const { memo, sat, msat, paymentHash, invoiceDate, expirationSeconds } = decodePaymentRequest(payment_request)
const message = await models.Message.create({
const msg:{[k:string]:any} = {
chatId: chat.id,
type: constants.message_types.invoice,
sender: sender.id,
@ -211,7 +211,12 @@ const receiveInvoice = async (payload) => {
status: constants.statuses.pending,
createdAt: date,
updatedAt: date
})
}
const isTribe = chat_type===constants.chat_types.tribe
if(isTribe) {
msg.senderAlias = sender_alias
}
const message = await models.Message.create(msg)
console.log('received keysend invoice message', message.id)
socket.sendJson({
@ -219,7 +224,7 @@ const receiveInvoice = async (payload) => {
response: jsonUtils.messageToJson(message, chat, sender)
})
sendNotification(chat, sender.alias, 'message')
sendNotification(chat, msg.senderAlias||sender.alias, 'message')
const theChat = {...chat.dataValues, contactIds:[sender.id]}
sendConfirmation({ chat:theChat, sender: owner, msg_id })

8
api/controllers/media.ts

@ -392,7 +392,7 @@ const receiveAttachment = async (payload) => {
var date = new Date();
date.setMilliseconds(0)
const {owner, sender, chat, mediaToken, mediaKey, mediaType, content, msg_id} = await helpers.parseReceiveParams(payload)
const {owner, sender, chat, mediaToken, mediaKey, mediaType, content, msg_id, chat_type, sender_alias} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
@ -409,6 +409,10 @@ const receiveAttachment = async (payload) => {
if(mediaToken) msg.mediaToken = mediaToken
if(mediaKey) msg.mediaKey = mediaKey
if(mediaType) msg.mediaType = mediaType
const isTribe = chat_type===constants.chat_types.tribe
if(isTribe) {
msg.senderAlias = sender_alias
}
const message = await models.Message.create(msg)
@ -419,7 +423,7 @@ const receiveAttachment = async (payload) => {
response: jsonUtils.messageToJson(message, chat, sender)
})
sendNotification(chat, sender.alias, 'message')
sendNotification(chat, msg.senderAlias||sender.alias, 'message')
const theChat = {...chat.dataValues, contactIds:[sender.id]}
sendConfirmation({ chat:theChat, sender: owner, msg_id })

2
api/controllers/messages.ts

@ -184,7 +184,7 @@ const receiveMessage = async (payload) => {
response: jsonUtils.messageToJson(message, chat, sender)
})
sendNotification(chat, sender.alias, 'message')
sendNotification(chat, msg.senderAlias||sender.alias, 'message')
const theChat = {...chat.dataValues, contactIds:[sender.id]}
sendConfirmation({ chat:theChat, sender: owner, msg_id })

7
api/controllers/payment.ts

@ -124,7 +124,7 @@ const receivePayment = async (payload) => {
var date = new Date();
date.setMilliseconds(0)
const {owner, sender, chat, amount, content, mediaType, mediaToken} = await helpers.parseReceiveParams(payload)
const {owner, sender, chat, amount, content, mediaType, mediaToken, chat_type, sender_alias} = await helpers.parseReceiveParams(payload)
if(!owner || !sender || !chat) {
return console.log('=> no group chat!')
}
@ -142,6 +142,9 @@ const receivePayment = async (payload) => {
if(content) msg.messageContent = content
if(mediaType) msg.mediaType = mediaType
if(mediaToken) msg.mediaToken = mediaToken
if(chat_type===constants.chat_types.tribe) {
msg.senderAlias = sender_alias
}
const message = await models.Message.create(msg)
@ -152,7 +155,7 @@ const receivePayment = async (payload) => {
response: jsonUtils.messageToJson(message, chat, sender)
})
sendNotification(chat, sender.alias, 'message')
sendNotification(chat, msg.senderAlias||sender.alias, 'message')
}
const listPayments = async (req, res) => {

2
dist/api/controllers/chats.js

@ -99,7 +99,7 @@ function createGroupChat(req, res) {
chatParams = yield createTribeChatParams(owner, contact_ids, name, img, price_per_message, price_to_join);
if (is_listed && chatParams.uuid) {
// publish to tribe server
tribes.declare(Object.assign(Object.assign({}, chatParams), { pricePerMessage: price_per_message, priceToJoin: price_to_join, description, tags, img }));
tribes.declare(Object.assign(Object.assign({}, chatParams), { pricePerMessage: price_per_message || 0, priceToJoin: price_to_join || 0, description, tags, img }));
}
// make me owner when i create
members[owner.publicKey].role = constants.chat_roles.owner;

2
dist/api/controllers/chats.js.map

File diff suppressed because one or more lines are too long

13
dist/api/controllers/invoices.js

@ -174,12 +174,12 @@ const receiveInvoice = (payload) => __awaiter(void 0, void 0, void 0, function*
const payment_request = dat.message.invoice;
var date = new Date();
date.setMilliseconds(0);
const { owner, sender, chat, msg_id } = yield helpers.parseReceiveParams(payload);
const { owner, sender, chat, msg_id, chat_type, sender_alias } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
const { memo, sat, msat, paymentHash, invoiceDate, expirationSeconds } = decodePaymentRequest(payment_request);
const message = yield models_1.models.Message.create({
const msg = {
chatId: chat.id,
type: constants.message_types.invoice,
sender: sender.id,
@ -194,13 +194,18 @@ const receiveInvoice = (payload) => __awaiter(void 0, void 0, void 0, function*
status: constants.statuses.pending,
createdAt: date,
updatedAt: date
});
};
const isTribe = chat_type === constants.chat_types.tribe;
if (isTribe) {
msg.senderAlias = sender_alias;
}
const message = yield models_1.models.Message.create(msg);
console.log('received keysend invoice message', message.id);
socket.sendJson({
type: 'invoice',
response: jsonUtils.messageToJson(message, chat, sender)
});
hub_1.sendNotification(chat, sender.alias, 'message');
hub_1.sendNotification(chat, msg.senderAlias || sender.alias, 'message');
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] });
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
});

2
dist/api/controllers/invoices.js.map

File diff suppressed because one or more lines are too long

8
dist/api/controllers/media.js

@ -359,7 +359,7 @@ const receiveAttachment = (payload) => __awaiter(void 0, void 0, void 0, functio
console.log('received attachment', { payload });
var date = new Date();
date.setMilliseconds(0);
const { owner, sender, chat, mediaToken, mediaKey, mediaType, content, msg_id } = yield helpers.parseReceiveParams(payload);
const { owner, sender, chat, mediaToken, mediaKey, mediaType, content, msg_id, chat_type, sender_alias } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
@ -379,13 +379,17 @@ const receiveAttachment = (payload) => __awaiter(void 0, void 0, void 0, functio
msg.mediaKey = mediaKey;
if (mediaType)
msg.mediaType = mediaType;
const isTribe = chat_type === constants.chat_types.tribe;
if (isTribe) {
msg.senderAlias = sender_alias;
}
const message = yield models_1.models.Message.create(msg);
// console.log('saved attachment', message.dataValues)
socket.sendJson({
type: 'attachment',
response: jsonUtils.messageToJson(message, chat, sender)
});
hub_1.sendNotification(chat, sender.alias, 'message');
hub_1.sendNotification(chat, msg.senderAlias || sender.alias, 'message');
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] });
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
});

2
dist/api/controllers/media.js.map

File diff suppressed because one or more lines are too long

2
dist/api/controllers/messages.js

@ -163,7 +163,7 @@ const receiveMessage = (payload) => __awaiter(void 0, void 0, void 0, function*
type: 'message',
response: jsonUtils.messageToJson(message, chat, sender)
});
hub_1.sendNotification(chat, sender.alias, 'message');
hub_1.sendNotification(chat, msg.senderAlias || sender.alias, 'message');
const theChat = Object.assign(Object.assign({}, chat.dataValues), { contactIds: [sender.id] });
confirmations_1.sendConfirmation({ chat: theChat, sender: owner, msg_id });
});

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

File diff suppressed because one or more lines are too long

7
dist/api/controllers/payment.js

@ -114,7 +114,7 @@ const receivePayment = (payload) => __awaiter(void 0, void 0, void 0, function*
console.log('received payment', { payload });
var date = new Date();
date.setMilliseconds(0);
const { owner, sender, chat, amount, content, mediaType, mediaToken } = yield helpers.parseReceiveParams(payload);
const { owner, sender, chat, amount, content, mediaType, mediaToken, chat_type, sender_alias } = yield helpers.parseReceiveParams(payload);
if (!owner || !sender || !chat) {
return console.log('=> no group chat!');
}
@ -134,13 +134,16 @@ const receivePayment = (payload) => __awaiter(void 0, void 0, void 0, function*
msg.mediaType = mediaType;
if (mediaToken)
msg.mediaToken = mediaToken;
if (chat_type === constants.chat_types.tribe) {
msg.senderAlias = sender_alias;
}
const message = yield models_1.models.Message.create(msg);
console.log('saved message', message.dataValues);
socket.sendJson({
type: 'direct_payment',
response: jsonUtils.messageToJson(message, chat, sender)
});
hub_1.sendNotification(chat, sender.alias, 'message');
hub_1.sendNotification(chat, msg.senderAlias || sender.alias, 'message');
});
exports.receivePayment = receivePayment;
const listPayments = (req, res) => __awaiter(void 0, void 0, void 0, function* () {

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

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save