Browse Source

sender alias in group join msg

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
9c9a7005de
  1. 14
      api/controllers/chats.ts
  2. 10
      dist/api/controllers/chats.js
  3. 2
      dist/api/controllers/chats.js.map

14
api/controllers/chats.ts

@ -302,7 +302,7 @@ async function receiveGroupLeave(payload) {
var date = new Date();
date.setMilliseconds(0)
const msg = {
const msg:{[k:string]:any} = {
chatId: chat.id,
type: constants.message_types.group_leave,
sender: (sender && sender.id) || 0,
@ -313,6 +313,9 @@ async function receiveGroupLeave(payload) {
createdAt: date,
updatedAt: date
}
if(isTribe) {
msg.senderAlias = sender_alias
}
const message = await models.Message.create(msg)
socket.sendJson({
@ -327,7 +330,7 @@ async function receiveGroupLeave(payload) {
async function receiveGroupJoin(payload) {
console.log('=> receiveGroupJoin')
const { sender_pub_key, chat_uuid, chat_members, chat_type, isTribeOwner } = await helpers.parseReceiveParams(payload)
const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner } = await helpers.parseReceiveParams(payload)
const chat = await models.Chat.findOne({ where: { uuid: chat_uuid } })
if (!chat) return
@ -339,7 +342,7 @@ async function receiveGroupJoin(payload) {
let theSender: any = null
const member = chat_members[sender_pub_key]
const senderAlias = (member && member.alias) || 'Unknown'
const senderAlias = sender_alias || (member && member.alias) || 'Unknown'
if(!isTribe || isTribeOwner) { // dont need to create contacts for these
const sender = await models.Contact.findOne({ where: { publicKey: sender_pub_key } })
@ -373,7 +376,7 @@ async function receiveGroupJoin(payload) {
}
}
const msg = {
const msg:{[k:string]:any} = {
chatId: chat.id,
type: constants.message_types.group_join,
sender: (theSender && theSender.id) || 0,
@ -384,6 +387,9 @@ async function receiveGroupJoin(payload) {
createdAt: date,
updatedAt: date
}
if(isTribe) {
msg.senderAlias = sender_alias
}
const message = await models.Message.create(msg)
socket.sendJson({

10
dist/api/controllers/chats.js

@ -299,6 +299,9 @@ function receiveGroupLeave(payload) {
createdAt: date,
updatedAt: date
};
if (isTribe) {
msg.senderAlias = sender_alias;
}
const message = yield models_1.models.Message.create(msg);
socket.sendJson({
type: 'group_leave',
@ -314,7 +317,7 @@ exports.receiveGroupLeave = receiveGroupLeave;
function receiveGroupJoin(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupJoin');
const { sender_pub_key, chat_uuid, chat_members, chat_type, isTribeOwner } = yield helpers.parseReceiveParams(payload);
const { sender_pub_key, sender_alias, chat_uuid, chat_members, chat_type, isTribeOwner } = yield helpers.parseReceiveParams(payload);
const chat = yield models_1.models.Chat.findOne({ where: { uuid: chat_uuid } });
if (!chat)
return;
@ -323,7 +326,7 @@ function receiveGroupJoin(payload) {
date.setMilliseconds(0);
let theSender = null;
const member = chat_members[sender_pub_key];
const senderAlias = (member && member.alias) || 'Unknown';
const senderAlias = sender_alias || (member && member.alias) || 'Unknown';
if (!isTribe || isTribeOwner) { // dont need to create contacts for these
const sender = yield models_1.models.Contact.findOne({ where: { publicKey: sender_pub_key } });
const contactIds = JSON.parse(chat.contactIds || '[]');
@ -367,6 +370,9 @@ function receiveGroupJoin(payload) {
createdAt: date,
updatedAt: date
};
if (isTribe) {
msg.senderAlias = sender_alias;
}
const message = yield models_1.models.Message.create(msg);
socket.sendJson({
type: 'group_join',

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

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