mirror of
https://github.com/abhinavxd/libredesk.git
synced 2025-10-23 05:11:57 +00:00
feat: adds waiting since in API responses and structs.
chore: rename senderTypeUser to senderTypeAgent to keep naming consistent.
This commit is contained in:
@@ -30,7 +30,7 @@ const (
|
||||
MessageOutgoing = "outgoing"
|
||||
MessageActivity = "activity"
|
||||
|
||||
SenderTypeUser = "user"
|
||||
SenderTypeAgent = "agent"
|
||||
SenderTypeContact = "contact"
|
||||
|
||||
MessageStatusPending = "pending"
|
||||
@@ -282,7 +282,7 @@ func (m *Manager) SendPrivateNote(media []mmodels.Media, senderID int, conversat
|
||||
ConversationUUID: conversationUUID,
|
||||
SenderID: senderID,
|
||||
Type: MessageOutgoing,
|
||||
SenderType: SenderTypeUser,
|
||||
SenderType: SenderTypeAgent,
|
||||
Status: MessageStatusSent,
|
||||
Content: content,
|
||||
ContentType: ContentTypeHTML,
|
||||
@@ -313,7 +313,7 @@ func (m *Manager) SendReply(media []mmodels.Media, senderID int, conversationUUI
|
||||
ConversationUUID: conversationUUID,
|
||||
SenderID: senderID,
|
||||
Type: MessageOutgoing,
|
||||
SenderType: SenderTypeUser,
|
||||
SenderType: SenderTypeAgent,
|
||||
Status: MessageStatusPending,
|
||||
Content: content,
|
||||
ContentType: ContentTypeHTML,
|
||||
@@ -418,7 +418,7 @@ func (m *Manager) InsertConversationActivity(activityType, conversationUUID, new
|
||||
ConversationUUID: conversationUUID,
|
||||
Private: true,
|
||||
SenderID: actor.ID,
|
||||
SenderType: SenderTypeUser,
|
||||
SenderType: SenderTypeAgent,
|
||||
}
|
||||
|
||||
if err := m.InsertMessage(&message); err != nil {
|
||||
|
@@ -46,6 +46,7 @@ type Conversation struct {
|
||||
AssignedUserID null.Int `db:"assigned_user_id" json:"assigned_user_id"`
|
||||
AssignedTeamID null.Int `db:"assigned_team_id" json:"assigned_team_id"`
|
||||
AssigneeLastSeenAt null.Time `db:"assignee_last_seen_at" json:"assignee_last_seen_at"`
|
||||
WaitingSince null.Time `db:"waiting_since" json:"waiting_since"`
|
||||
Subject null.String `db:"subject" json:"subject"`
|
||||
UnreadMessageCount int `db:"unread_message_count" json:"unread_message_count"`
|
||||
InboxName string `db:"inbox_name" json:"inbox_name"`
|
||||
|
@@ -32,6 +32,7 @@ SELECT
|
||||
conversations.created_at,
|
||||
conversations.updated_at,
|
||||
conversations.uuid,
|
||||
conversations.waiting_since,
|
||||
conversations.assignee_last_seen_at,
|
||||
users.created_at as "contact.created_at",
|
||||
users.updated_at as "contact.updated_at",
|
||||
@@ -96,6 +97,7 @@ SELECT
|
||||
c.uuid,
|
||||
c.reference_number,
|
||||
c.first_reply_at,
|
||||
c.waiting_since,
|
||||
c.assigned_user_id,
|
||||
c.assigned_team_id,
|
||||
c.subject,
|
||||
@@ -461,16 +463,18 @@ inserted_msg AS (
|
||||
$1, $2, (SELECT id FROM conversation_id),
|
||||
$5, $6, $7, $8, $9, $10, $11, $12
|
||||
)
|
||||
RETURNING id, uuid, created_at
|
||||
RETURNING id, uuid, created_at, conversation_id
|
||||
),
|
||||
updated_conversation AS (
|
||||
UPDATE conversations
|
||||
SET waiting_since = CASE
|
||||
WHEN $8 = 'contact' THEN NOW()
|
||||
WHEN $8 = 'agent' THEN NULL
|
||||
ELSE waiting_since
|
||||
END
|
||||
WHERE id = (SELECT id FROM conversation_id)
|
||||
)
|
||||
UPDATE conversations
|
||||
SET waiting_since = CASE
|
||||
WHEN $8 = 'contact' THEN NOW()
|
||||
WHEN $8 = 'agent' THEN NULL
|
||||
ELSE waiting_since
|
||||
END
|
||||
WHERE id = (SELECT id FROM conversation_id)
|
||||
RETURNING (SELECT * FROM inserted_msg);
|
||||
SELECT id, uuid, created_at FROM inserted_msg;
|
||||
|
||||
-- name: message-exists-by-source-id
|
||||
SELECT conversation_id
|
||||
|
@@ -2,7 +2,7 @@ CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
|
||||
DROP TYPE IF EXISTS "channels" CASCADE; CREATE TYPE "channels" AS ENUM ('email');
|
||||
DROP TYPE IF EXISTS "message_type" CASCADE; CREATE TYPE "message_type" AS ENUM ('incoming','outgoing','activity');
|
||||
DROP TYPE IF EXISTS "message_sender_type" CASCADE; CREATE TYPE "message_sender_type" AS ENUM ('user','contact');
|
||||
DROP TYPE IF EXISTS "message_sender_type" CASCADE; CREATE TYPE "message_sender_type" AS ENUM ('agent','contact');
|
||||
DROP TYPE IF EXISTS "message_status" CASCADE; CREATE TYPE "message_status" AS ENUM ('received','sent','failed','pending');
|
||||
DROP TYPE IF EXISTS "content_type" CASCADE; CREATE TYPE "content_type" AS ENUM ('text','html');
|
||||
DROP TYPE IF EXISTS "conversation_assignment_type" CASCADE; CREATE TYPE "conversation_assignment_type" AS ENUM ('Round robin','Manual');
|
||||
|
Reference in New Issue
Block a user