Browse Source

fix

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

12
api/controllers/chats.ts

@ -94,6 +94,7 @@ async function createGroupChat(req, res) {
}) })
} }
// only owner can do for tribe?
async function addGroupMembers(req, res) { async function addGroupMembers(req, res) {
const { const {
contact_ids, contact_ids,
@ -201,7 +202,7 @@ async function receiveGroupLeave(payload) {
} }
// here: can only join if enough $$$! // here: can only join if enough $$$!
// need to forward to all tho? // forward to all over mqtt
async function receiveGroupJoin(payload) { async function receiveGroupJoin(payload) {
console.log('=> receiveGroupJoin') console.log('=> receiveGroupJoin')
const { sender_pub_key, chat_uuid, chat_members } = await helpers.parseReceiveParams(payload) const { sender_pub_key, chat_uuid, chat_members } = await helpers.parseReceiveParams(payload)
@ -278,10 +279,10 @@ async function receiveGroupCreateOrInvite(payload) {
alias: member.alias||'Unknown', alias: member.alias||'Unknown',
status: 1 status: 1
}) })
contacts.push({...createdContact,role:member.role}) contacts.push({...createdContact.dataValues,role:member.role})
newContacts.push(createdContact.dataValues) newContacts.push(createdContact.dataValues)
} else { } 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 }, ...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=>{ contacts.forEach(c=>{
models.ChatMember.create({ models.ChatMember.create({
contactId: c.id, contactId: c.id,
@ -339,7 +341,7 @@ async function receiveGroupCreateOrInvite(payload) {
} }
function createGroupChatParams(owner, contactIds, members, name) { function createGroupChatParams(owner, contactIds, members, name) {
let date = new Date(); let date = new Date()
date.setMilliseconds(0) date.setMilliseconds(0)
if (!(owner && members && contactIds && Array.isArray(contactIds))) { if (!(owner && members && contactIds && Array.isArray(contactIds))) {
return return

10
dist/api/controllers/chats.js

@ -96,6 +96,7 @@ function createGroupChat(req, res) {
}); });
} }
exports.createGroupChat = createGroupChat; exports.createGroupChat = createGroupChat;
// only owner can do for tribe?
function addGroupMembers(req, res) { function addGroupMembers(req, res) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { contact_ids, } = req.body; const { contact_ids, } = req.body;
@ -196,7 +197,7 @@ function receiveGroupLeave(payload) {
} }
exports.receiveGroupLeave = receiveGroupLeave; exports.receiveGroupLeave = receiveGroupLeave;
// here: can only join if enough $$$! // here: can only join if enough $$$!
// need to forward to all tho? // forward to all over mqtt
function receiveGroupJoin(payload) { function receiveGroupJoin(payload) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveGroupJoin'); console.log('=> receiveGroupJoin');
@ -275,11 +276,11 @@ function receiveGroupCreateOrInvite(payload) {
alias: member.alias || 'Unknown', alias: member.alias || 'Unknown',
status: 1 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); newContacts.push(createdContact.dataValues);
} }
else { 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(); let date = new Date();
date.setMilliseconds(0); 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 })); 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 => { contacts.forEach(c => {
models_1.models.ChatMember.create({ models_1.models.ChatMember.create({
contactId: c.id, contactId: c.id,

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

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