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"
|
MessageOutgoing = "outgoing"
|
||||||
MessageActivity = "activity"
|
MessageActivity = "activity"
|
||||||
|
|
||||||
SenderTypeUser = "user"
|
SenderTypeAgent = "agent"
|
||||||
SenderTypeContact = "contact"
|
SenderTypeContact = "contact"
|
||||||
|
|
||||||
MessageStatusPending = "pending"
|
MessageStatusPending = "pending"
|
||||||
@@ -282,7 +282,7 @@ func (m *Manager) SendPrivateNote(media []mmodels.Media, senderID int, conversat
|
|||||||
ConversationUUID: conversationUUID,
|
ConversationUUID: conversationUUID,
|
||||||
SenderID: senderID,
|
SenderID: senderID,
|
||||||
Type: MessageOutgoing,
|
Type: MessageOutgoing,
|
||||||
SenderType: SenderTypeUser,
|
SenderType: SenderTypeAgent,
|
||||||
Status: MessageStatusSent,
|
Status: MessageStatusSent,
|
||||||
Content: content,
|
Content: content,
|
||||||
ContentType: ContentTypeHTML,
|
ContentType: ContentTypeHTML,
|
||||||
@@ -313,7 +313,7 @@ func (m *Manager) SendReply(media []mmodels.Media, senderID int, conversationUUI
|
|||||||
ConversationUUID: conversationUUID,
|
ConversationUUID: conversationUUID,
|
||||||
SenderID: senderID,
|
SenderID: senderID,
|
||||||
Type: MessageOutgoing,
|
Type: MessageOutgoing,
|
||||||
SenderType: SenderTypeUser,
|
SenderType: SenderTypeAgent,
|
||||||
Status: MessageStatusPending,
|
Status: MessageStatusPending,
|
||||||
Content: content,
|
Content: content,
|
||||||
ContentType: ContentTypeHTML,
|
ContentType: ContentTypeHTML,
|
||||||
@@ -418,7 +418,7 @@ func (m *Manager) InsertConversationActivity(activityType, conversationUUID, new
|
|||||||
ConversationUUID: conversationUUID,
|
ConversationUUID: conversationUUID,
|
||||||
Private: true,
|
Private: true,
|
||||||
SenderID: actor.ID,
|
SenderID: actor.ID,
|
||||||
SenderType: SenderTypeUser,
|
SenderType: SenderTypeAgent,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.InsertMessage(&message); err != nil {
|
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"`
|
AssignedUserID null.Int `db:"assigned_user_id" json:"assigned_user_id"`
|
||||||
AssignedTeamID null.Int `db:"assigned_team_id" json:"assigned_team_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"`
|
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"`
|
Subject null.String `db:"subject" json:"subject"`
|
||||||
UnreadMessageCount int `db:"unread_message_count" json:"unread_message_count"`
|
UnreadMessageCount int `db:"unread_message_count" json:"unread_message_count"`
|
||||||
InboxName string `db:"inbox_name" json:"inbox_name"`
|
InboxName string `db:"inbox_name" json:"inbox_name"`
|
||||||
|
@@ -32,6 +32,7 @@ SELECT
|
|||||||
conversations.created_at,
|
conversations.created_at,
|
||||||
conversations.updated_at,
|
conversations.updated_at,
|
||||||
conversations.uuid,
|
conversations.uuid,
|
||||||
|
conversations.waiting_since,
|
||||||
conversations.assignee_last_seen_at,
|
conversations.assignee_last_seen_at,
|
||||||
users.created_at as "contact.created_at",
|
users.created_at as "contact.created_at",
|
||||||
users.updated_at as "contact.updated_at",
|
users.updated_at as "contact.updated_at",
|
||||||
@@ -96,6 +97,7 @@ SELECT
|
|||||||
c.uuid,
|
c.uuid,
|
||||||
c.reference_number,
|
c.reference_number,
|
||||||
c.first_reply_at,
|
c.first_reply_at,
|
||||||
|
c.waiting_since,
|
||||||
c.assigned_user_id,
|
c.assigned_user_id,
|
||||||
c.assigned_team_id,
|
c.assigned_team_id,
|
||||||
c.subject,
|
c.subject,
|
||||||
@@ -461,16 +463,18 @@ inserted_msg AS (
|
|||||||
$1, $2, (SELECT id FROM conversation_id),
|
$1, $2, (SELECT id FROM conversation_id),
|
||||||
$5, $6, $7, $8, $9, $10, $11, $12
|
$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
|
SELECT id, uuid, created_at FROM inserted_msg;
|
||||||
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);
|
|
||||||
|
|
||||||
-- name: message-exists-by-source-id
|
-- name: message-exists-by-source-id
|
||||||
SELECT conversation_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 "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_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 "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 "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');
|
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