feature/IO-3000-messaging-sockets-migrations2 -
- Checkpoint, Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -22,6 +22,7 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
query: CONVERSATION_LIST_QUERY,
|
query: CONVERSATION_LIST_QUERY,
|
||||||
variables: { offset: 0 }
|
variables: { offset: 0 }
|
||||||
});
|
});
|
||||||
|
|
||||||
client.cache.writeQuery({
|
client.cache.writeQuery({
|
||||||
query: CONVERSATION_LIST_QUERY,
|
query: CONVERSATION_LIST_QUERY,
|
||||||
variables: { offset: 0 },
|
variables: { offset: 0 },
|
||||||
@@ -49,7 +50,14 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
id: conversationId
|
id: conversationId
|
||||||
}),
|
}),
|
||||||
fields: {
|
fields: {
|
||||||
updated_at: () => new Date(),
|
updated_at: () => new Date().toISOString(),
|
||||||
|
archived(cached) {
|
||||||
|
// Unarchive the conversation if it was previously marked as archived
|
||||||
|
if (cached) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return cached;
|
||||||
|
},
|
||||||
messages_aggregate(cached) {
|
messages_aggregate(cached) {
|
||||||
// Increment unread count only if the message is inbound
|
// Increment unread count only if the message is inbound
|
||||||
if (!isoutbound) {
|
if (!isoutbound) {
|
||||||
|
|||||||
@@ -90,9 +90,25 @@ export const CONVERSATION_ID_BY_PHONE = gql`
|
|||||||
query CONVERSATION_ID_BY_PHONE($phone: String!) {
|
query CONVERSATION_ID_BY_PHONE($phone: String!) {
|
||||||
conversations(where: { phone_num: { _eq: $phone } }) {
|
conversations(where: { phone_num: { _eq: $phone } }) {
|
||||||
id
|
id
|
||||||
|
phone_num
|
||||||
|
archived
|
||||||
|
label
|
||||||
|
unreadcnt
|
||||||
job_conversations {
|
job_conversations {
|
||||||
jobid
|
jobid
|
||||||
id
|
conversationid
|
||||||
|
job {
|
||||||
|
id
|
||||||
|
ownr_fn
|
||||||
|
ownr_ln
|
||||||
|
ownr_co_nm
|
||||||
|
ro_number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messages_aggregate(where: { read: { _eq: false }, isoutbound: { _eq: false } }) {
|
||||||
|
aggregate {
|
||||||
|
count
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ exports.receive = async (req, res) => {
|
|||||||
newMessage.conversation = {
|
newMessage.conversation = {
|
||||||
data: {
|
data: {
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
phone_num: phone(req.body.From).phoneNumber
|
phone_num: phone(req.body.From).phoneNumber,
|
||||||
|
archived: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user