Browse Source

fix

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
084fca5899
  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

@ -94,6 +94,7 @@ async function createGroupChat(req, res) {
})
}
// only owner can do for tribe?
async function addGroupMembers(req, res) {
const {
contact_ids,
@ -201,7 +202,7 @@ async function receiveGroupLeave(payload) {
}
// here: can only join if enough $$$!
// need to forward to all tho?
// forward to all over mqtt
async function receiveGroupJoin(payload) {
console.log('=> receiveGroupJoin')
const { sender_pub_key, chat_uuid, chat_members } = await helpers.parseReceiveParams(payload)
@ -268,7 +269,7 @@ async function receiveGroupCreateOrInvite(payload) {
} else if(chat_type===constants.chat_types.tribe && member && member.role) {
if (member.role===constants.chat_roles.owner || member.role===constants.chat_roles.admin || member.role===constants.chat_roles.mode){
addContact = true
}
}
}
if(addContact){
if (!contact) {
@ -278,10 +279,10 @@ async function receiveGroupCreateOrInvite(payload) {
alias: member.alias||'Unknown',
status: 1
})
contacts.push({...createdContact,role:member.role})
contacts.push({...createdContact.dataValues,role:member.role})
newContacts.push(createdContact.dataValues)
} else {
contacts.push({...contact,role:member.role})
contacts.push({...contact.dataValues,role:member.role})
}
}
}
@ -302,7 +303,8 @@ async function receiveGroupCreateOrInvite(payload) {
...chat_key && { groupKey: chat_key },
})
if(chat_type===constants.chat_types.tribe){ // IF TRIBE, ADD TO XREF
// IF TRIBE, ADD TO XREF
if(chat_type===constants.chat_types.tribe){
contacts.forEach(c=>{
models.ChatMember.create({
contactId: c.id,
@ -339,7 +341,7 @@ async function receiveGroupCreateOrInvite(payload) {
}
function createGroupChatParams(owner, contactIds, members, name) {
let date = new Date();
let date = new Date()
date.setMilliseconds(0)
if (!(owner && members && contactIds && Array.isArray(contactIds))) {
return

10
dist/api/controllers/chats.js

@ -96,6 +96,7 @@ function createGroupChat(req, res) {
});
}
exports.createGroupChat = createGroupChat;
// only owner can do for tribe?
function addGroupMembers(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const { contact_ids, } = req.body;
@ -196,7 +197,7 @@ function receiveGroupLeave(payload) {
}
exports.receiveGroupLeave = receiveGroupLeave;
// here: can only join if enough $$$!
// need to forward to all tho?
// forward to all over mqtt
function receiveGroupJoin(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupJoin');
@ -275,11 +276,11 @@ function receiveGroupCreateOrInvite(payload) {
alias: member.alias || 'Unknown',
status: 1
});
contacts.push(Object.assign(Object.assign({}, createdContact), { role: member.role }));
contacts.push(Object.assign(Object.assign({}, createdContact.dataValues), { role: member.role }));
newContacts.push(createdContact.dataValues);
}
else {
contacts.push(Object.assign(Object.assign({}, contact), { role: member.role }));
contacts.push(Object.assign(Object.assign({}, contact.dataValues), { role: member.role }));
}
}
}
@ -291,7 +292,8 @@ function receiveGroupCreateOrInvite(payload) {
let date = new Date();
date.setMilliseconds(0);
const chat = yield models_1.models.Chat.create(Object.assign(Object.assign({ uuid: chat_uuid, contactIds: JSON.stringify(contactIds), createdAt: date, updatedAt: date, name: chat_name, type: chat_type || constants.chat_types.group }, chat_host && { host: chat_host }), chat_key && { groupKey: chat_key }));
if (chat_type === constants.chat_types.tribe) { // IF TRIBE, ADD TO XREF
// IF TRIBE, ADD TO XREF
if (chat_type === constants.chat_types.tribe) {
contacts.forEach(c => {
models_1.models.ChatMember.create({
contactId: c.id,

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

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