mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-10 14:15:42 +00:00
fix new inbox create dropping enabled/csat_enabled/secret/linked_email_inbox_id
This commit is contained in:
@@ -119,6 +119,8 @@ const submitForm = (values) => {
|
||||
name: values.name,
|
||||
from: values.from,
|
||||
channel: channelName,
|
||||
enabled: values.enabled ?? true,
|
||||
csat_enabled: values.csat_enabled ?? false,
|
||||
prompt_tags_on_reply: values.prompt_tags_on_reply ?? false,
|
||||
config: {
|
||||
reply_to: values.reply_to,
|
||||
@@ -137,6 +139,8 @@ const submitLiveChatForm = (values) => {
|
||||
enabled: values.enabled ?? true,
|
||||
csat_enabled: values.csat_enabled ?? false,
|
||||
prompt_tags_on_reply: values.prompt_tags_on_reply ?? false,
|
||||
secret: values.secret ?? '',
|
||||
linked_email_inbox_id: values.linked_email_inbox_id ?? null,
|
||||
config: values.config
|
||||
}
|
||||
createInbox(payload)
|
||||
|
||||
@@ -230,11 +230,14 @@ func (m *Manager) GetAll() ([]imodels.Inbox, error) {
|
||||
|
||||
// Create creates an inbox in the DB.
|
||||
func (m *Manager) Create(inbox imodels.Inbox) (imodels.Inbox, error) {
|
||||
// Generate and encrypt secret for livechat inboxes if not provided
|
||||
if inbox.Channel == ChannelLiveChat && !inbox.Secret.Valid {
|
||||
secret, err := stringutil.RandomAlphanumeric(32)
|
||||
if err != nil {
|
||||
return imodels.Inbox{}, fmt.Errorf("generating inbox secret: %w", err)
|
||||
if inbox.Channel == ChannelLiveChat {
|
||||
secret := inbox.Secret.String
|
||||
if secret == "" {
|
||||
generated, err := stringutil.RandomAlphanumeric(32)
|
||||
if err != nil {
|
||||
return imodels.Inbox{}, fmt.Errorf("generating inbox secret: %w", err)
|
||||
}
|
||||
secret = generated
|
||||
}
|
||||
encryptedSecret, err := crypto.Encrypt(secret, m.encryptionKey)
|
||||
if err != nil {
|
||||
@@ -251,7 +254,7 @@ func (m *Manager) Create(inbox imodels.Inbox) (imodels.Inbox, error) {
|
||||
}
|
||||
|
||||
var createdInbox imodels.Inbox
|
||||
if err := m.queries.InsertInbox.Get(&createdInbox, inbox.Channel, encryptedConfig, inbox.Name, inbox.From, inbox.CSATEnabled, inbox.PromptTagsOnReply, inbox.Secret, inbox.LinkedEmailInboxID); err != nil {
|
||||
if err := m.queries.InsertInbox.Get(&createdInbox, inbox.Channel, encryptedConfig, inbox.Name, inbox.From, inbox.Enabled, inbox.CSATEnabled, inbox.PromptTagsOnReply, inbox.Secret, inbox.LinkedEmailInboxID); err != nil {
|
||||
m.lo.Error("error creating inbox", "error", err)
|
||||
return imodels.Inbox{}, envelope.NewError(envelope.GeneralError, m.i18n.T("globals.messages.somethingWentWrong"), nil)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ SELECT id, uuid, created_at, updated_at, "name", deleted_at, channel, enabled, c
|
||||
|
||||
-- name: insert-inbox
|
||||
INSERT INTO inboxes
|
||||
(channel, config, "name", "from", csat_enabled, prompt_tags_on_reply, secret, linked_email_inbox_id)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
(channel, config, "name", "from", enabled, csat_enabled, prompt_tags_on_reply, secret, linked_email_inbox_id)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
RETURNING *
|
||||
|
||||
-- name: get-inbox
|
||||
|
||||
Reference in New Issue
Block a user