mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-23 02:53:32 +00:00
494bc15b0a
Before this feature the only way to create a conversation was by adding inbox and sending an email. Agents first search contacts by email, see a dropdown select an existing contact or fill a new email for new contact. The backend creates contact if it does not exist, creates a conversation, sends a reply to the conversation. Optinally assigns conversation to a user / team. fix: Replies to emails create a new conversation instead of attaching to the previous one. Was not happening in gmail, as gmail was sending the references headers in all replies and I missed this completely. So when libredesk searches a conversation by references headers it worked! Instead the right way is to generate the outgoing email message id and saving it in DB. This commit fixes that. There could be more backup strategies like putting reference number in the subject but that can be explored later. chore: new role `conversatons:write` that enables the create conversations feature for an agent. chore: migrations for v0.4.0.
32 lines
751 B
SQL
32 lines
751 B
SQL
-- name: search-conversations
|
|
SELECT
|
|
conversations.created_at,
|
|
conversations.uuid,
|
|
conversations.reference_number,
|
|
conversations.subject
|
|
FROM conversations
|
|
WHERE reference_number::text = $1;
|
|
|
|
-- name: search-messages
|
|
SELECT
|
|
c.created_at as "conversation_created_at",
|
|
c.reference_number as "conversation_reference_number",
|
|
c.uuid as "conversation_uuid",
|
|
m.text_content
|
|
FROM conversation_messages m
|
|
JOIN conversations c ON m.conversation_id = c.id
|
|
WHERE m.type != 'activity' and m.text_content ILIKE '%' || $1 || '%';
|
|
|
|
-- name: search-contacts
|
|
SELECT
|
|
id,
|
|
created_at,
|
|
first_name,
|
|
last_name,
|
|
email
|
|
FROM users
|
|
WHERE type = 'contact'
|
|
AND deleted_at IS NULL
|
|
AND email ILIKE '%' || $1 || '%'
|
|
LIMIT 15;
|