Browse Source

only send group_leave if Chat not in pending state

push-params
Evan Feenstra 5 years ago
parent
commit
7312b21076
  1. 6
      api/controllers/chatTribes.ts
  2. 15
      api/controllers/chats.ts
  3. 6
      dist/api/controllers/chatTribes.js
  4. 2
      dist/api/controllers/chatTribes.js.map
  5. 15
      dist/api/controllers/chats.js
  6. 2
      dist/api/controllers/chats.js.map

6
api/controllers/chatTribes.ts

@ -175,7 +175,7 @@ export async function receiveMemberRequest(payload) {
response: {
contact: jsonUtils.contactToJson(theSender||{}),
chat: jsonUtils.chatToJson(theChat),
message: jsonUtils.messageToJson(message, null)
message: jsonUtils.messageToJson(message, theChat)
}
})
}
@ -305,7 +305,7 @@ export async function receiveMemberApprove(payload) {
socket.sendJson({
type: 'member_approve',
response: {
message: jsonUtils.messageToJson(message, null),
message: jsonUtils.messageToJson(message, chat),
chat: jsonUtils.chatToJson(chat),
}
})
@ -351,7 +351,7 @@ export async function receiveMemberReject(payload) {
socket.sendJson({
type: 'member_reject',
response: {
message: jsonUtils.messageToJson(message, null),
message: jsonUtils.messageToJson(message, chat),
chat: jsonUtils.chatToJson(chat),
}
})

15
api/controllers/chats.ts

@ -276,12 +276,15 @@ export const deleteChat = async (req, res) => {
return failure(res, "cannot leave your own tribe")
}
network.sendMessage({
chat,
sender: owner,
message: {},
type: constants.message_types.group_leave,
})
const isPending = chat.status===constants.chat_types.pending
if(!isPending) { // dont send if pending
network.sendMessage({
chat,
sender: owner,
message: {},
type: constants.message_types.group_leave,
})
}
await chat.update({
deleted: true,

6
dist/api/controllers/chatTribes.js

@ -175,7 +175,7 @@ function receiveMemberRequest(payload) {
response: {
contact: jsonUtils.contactToJson(theSender || {}),
chat: jsonUtils.chatToJson(theChat),
message: jsonUtils.messageToJson(message, null)
message: jsonUtils.messageToJson(message, theChat)
}
});
});
@ -295,7 +295,7 @@ function receiveMemberApprove(payload) {
socket.sendJson({
type: 'member_approve',
response: {
message: jsonUtils.messageToJson(message, null),
message: jsonUtils.messageToJson(message, chat),
chat: jsonUtils.chatToJson(chat),
}
});
@ -340,7 +340,7 @@ function receiveMemberReject(payload) {
socket.sendJson({
type: 'member_reject',
response: {
message: jsonUtils.messageToJson(message, null),
message: jsonUtils.messageToJson(message, chat),
chat: jsonUtils.chatToJson(chat),
}
});

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

File diff suppressed because one or more lines are too long

15
dist/api/controllers/chats.js

@ -270,12 +270,15 @@ exports.deleteChat = (req, res) => __awaiter(void 0, void 0, void 0, function* (
if (owner.publicKey === tribeOwnerPubKey) {
return res_1.failure(res, "cannot leave your own tribe");
}
network.sendMessage({
chat,
sender: owner,
message: {},
type: constants.message_types.group_leave,
});
const isPending = chat.status === constants.chat_types.pending;
if (!isPending) { // dont send if pending
network.sendMessage({
chat,
sender: owner,
message: {},
type: constants.message_types.group_leave,
});
}
yield chat.update({
deleted: true,
uuid: '',

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

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