IO-1124 Archive message

This commit is contained in:
Patrick Fic
2021-06-09 09:59:49 -07:00
parent a45bf6d959
commit 7a8e8de724
9 changed files with 116 additions and 10 deletions

View File

@@ -13,7 +13,10 @@ query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
`;
exports.INSERT_MESSAGE = `
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!, $conversationid: uuid) {
update_conversations(where: {id: {_eq: $conversationid}}, _set: {archived: false}) {
affected_rows
}
insert_messages(objects: $msg) {
returning {
conversation {
@@ -28,6 +31,7 @@ mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
}
}
}
`;
exports.UPDATE_MESSAGE_STATUS = `

View File

@@ -62,13 +62,17 @@ exports.receive = (req, res) => {
}
client
.request(queries.INSERT_MESSAGE, { msg: newMessage })
.request(queries.INSERT_MESSAGE, {
msg: newMessage,
conversationid: response.bodyshops[0].conversations[0].id,
})
.then((r2) => {
res.status(200).send("");
const arrayOfAllUserFcmTokens = r2.insert_messages.returning[0].conversation.bodyshop.associations.map(
(a) => a.user.fcmtokens
);
const arrayOfAllUserFcmTokens =
r2.insert_messages.returning[0].conversation.bodyshop.associations.map(
(a) => a.user.fcmtokens
);
const allTokens = [];
arrayOfAllUserFcmTokens.map((i) =>
Object.keys(i).map((k) => allTokens.push(k))