fix: Remove IMAP and SMTP email validation (#4435)
* Remove IMAP and SMTP email validation * Rename imap_email & smtp_email columns to imap_login & smtp_login respectively. * Use channel email domain if inbound email domain not present
This commit is contained in:
parent
3d164271a8
commit
31cdc63e18
17 changed files with 86 additions and 53 deletions
|
@ -14,7 +14,7 @@ module Api::V1::InboxesHelper
|
||||||
Mail.defaults do
|
Mail.defaults do
|
||||||
retriever_method :imap, { address: channel_data[:imap_address],
|
retriever_method :imap, { address: channel_data[:imap_address],
|
||||||
port: channel_data[:imap_port],
|
port: channel_data[:imap_port],
|
||||||
user_name: channel_data[:imap_email],
|
user_name: channel_data[:imap_login],
|
||||||
password: channel_data[:imap_password],
|
password: channel_data[:imap_password],
|
||||||
enable_ssl: channel_data[:imap_enable_ssl] }
|
enable_ssl: channel_data[:imap_enable_ssl] }
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,7 @@ module Api::V1::InboxesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_smtp_connection(channel_data, smtp)
|
def check_smtp_connection(channel_data, smtp)
|
||||||
smtp.start(channel_data[:smtp_domain], channel_data[:smtp_email], channel_data[:smtp_password],
|
smtp.start(channel_data[:smtp_domain], channel_data[:smtp_login], channel_data[:smtp_password],
|
||||||
channel_data[:smtp_authentication]&.to_sym || :login)
|
channel_data[:smtp_authentication]&.to_sym || :login)
|
||||||
smtp.finish unless smtp&.nil?
|
smtp.finish unless smtp&.nil?
|
||||||
end
|
end
|
||||||
|
|
|
@ -486,9 +486,9 @@
|
||||||
"LABEL": "Port",
|
"LABEL": "Port",
|
||||||
"PLACE_HOLDER": "Port"
|
"PLACE_HOLDER": "Port"
|
||||||
},
|
},
|
||||||
"EMAIL": {
|
"LOGIN": {
|
||||||
"LABEL": "Email",
|
"LABEL": "Login",
|
||||||
"PLACE_HOLDER": "Email"
|
"PLACE_HOLDER": "Login"
|
||||||
},
|
},
|
||||||
"PASSWORD": {
|
"PASSWORD": {
|
||||||
"LABEL": "Password",
|
"LABEL": "Password",
|
||||||
|
@ -514,9 +514,9 @@
|
||||||
"LABEL": "Port",
|
"LABEL": "Port",
|
||||||
"PLACE_HOLDER": "Port"
|
"PLACE_HOLDER": "Port"
|
||||||
},
|
},
|
||||||
"EMAIL": {
|
"LOGIN": {
|
||||||
"LABEL": "Email",
|
"LABEL": "Login",
|
||||||
"PLACE_HOLDER": "Email"
|
"PLACE_HOLDER": "Login"
|
||||||
},
|
},
|
||||||
"PASSWORD": {
|
"PASSWORD": {
|
||||||
"LABEL": "Password",
|
"LABEL": "Password",
|
||||||
|
|
|
@ -34,12 +34,12 @@
|
||||||
@blur="$v.port.$touch"
|
@blur="$v.port.$touch"
|
||||||
/>
|
/>
|
||||||
<woot-input
|
<woot-input
|
||||||
v-model="email"
|
v-model="login"
|
||||||
:class="{ error: $v.email.$error }"
|
:class="{ error: $v.login.$error }"
|
||||||
class="medium-9 columns"
|
class="medium-9 columns"
|
||||||
:label="$t('INBOX_MGMT.IMAP.EMAIL.LABEL')"
|
:label="$t('INBOX_MGMT.IMAP.LOGIN.LABEL')"
|
||||||
:placeholder="$t('INBOX_MGMT.IMAP.EMAIL.PLACE_HOLDER')"
|
:placeholder="$t('INBOX_MGMT.IMAP.LOGIN.PLACE_HOLDER')"
|
||||||
@blur="$v.email.$touch"
|
@blur="$v.login.$touch"
|
||||||
/>
|
/>
|
||||||
<woot-input
|
<woot-input
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import SettingsSection from 'dashboard/components/SettingsSection';
|
import SettingsSection from 'dashboard/components/SettingsSection';
|
||||||
import { required, minLength, email } from 'vuelidate/lib/validators';
|
import { required, minLength } from 'vuelidate/lib/validators';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
@ -91,7 +91,7 @@ export default {
|
||||||
isIMAPEnabled: false,
|
isIMAPEnabled: false,
|
||||||
address: '',
|
address: '',
|
||||||
port: '',
|
port: '',
|
||||||
email: '',
|
login: '',
|
||||||
password: '',
|
password: '',
|
||||||
isSSLEnabled: true,
|
isSSLEnabled: true,
|
||||||
};
|
};
|
||||||
|
@ -99,7 +99,7 @@ export default {
|
||||||
validations: {
|
validations: {
|
||||||
address: { required },
|
address: { required },
|
||||||
port: { required, minLength: minLength(2) },
|
port: { required, minLength: minLength(2) },
|
||||||
email: { required, email },
|
login: { required },
|
||||||
password: { required },
|
password: { required },
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -119,14 +119,14 @@ export default {
|
||||||
imap_enabled,
|
imap_enabled,
|
||||||
imap_address,
|
imap_address,
|
||||||
imap_port,
|
imap_port,
|
||||||
imap_email,
|
imap_login,
|
||||||
imap_password,
|
imap_password,
|
||||||
imap_enable_ssl,
|
imap_enable_ssl,
|
||||||
} = this.inbox;
|
} = this.inbox;
|
||||||
this.isIMAPEnabled = imap_enabled;
|
this.isIMAPEnabled = imap_enabled;
|
||||||
this.address = imap_address;
|
this.address = imap_address;
|
||||||
this.port = imap_port;
|
this.port = imap_port;
|
||||||
this.email = imap_email;
|
this.login = imap_login;
|
||||||
this.password = imap_password;
|
this.password = imap_password;
|
||||||
this.isSSLEnabled = imap_enable_ssl;
|
this.isSSLEnabled = imap_enable_ssl;
|
||||||
},
|
},
|
||||||
|
@ -140,7 +140,7 @@ export default {
|
||||||
imap_enabled: this.isIMAPEnabled,
|
imap_enabled: this.isIMAPEnabled,
|
||||||
imap_address: this.address,
|
imap_address: this.address,
|
||||||
imap_port: this.port,
|
imap_port: this.port,
|
||||||
imap_email: this.email,
|
imap_login: this.login,
|
||||||
imap_password: this.password,
|
imap_password: this.password,
|
||||||
imap_enable_ssl: this.isSSLEnabled,
|
imap_enable_ssl: this.isSSLEnabled,
|
||||||
imap_inbox_synced_at: this.isIMAPEnabled
|
imap_inbox_synced_at: this.isIMAPEnabled
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
@blur="$v.port.$touch"
|
@blur="$v.port.$touch"
|
||||||
/>
|
/>
|
||||||
<woot-input
|
<woot-input
|
||||||
v-model="email"
|
v-model="login"
|
||||||
:class="{ error: $v.email.$error }"
|
:class="{ error: $v.login.$error }"
|
||||||
class="medium-9 columns"
|
class="medium-9 columns"
|
||||||
:label="$t('INBOX_MGMT.SMTP.EMAIL.LABEL')"
|
:label="$t('INBOX_MGMT.SMTP.LOGIN.LABEL')"
|
||||||
:placeholder="$t('INBOX_MGMT.SMTP.EMAIL.PLACE_HOLDER')"
|
:placeholder="$t('INBOX_MGMT.SMTP.LOGIN.PLACE_HOLDER')"
|
||||||
@blur="$v.email.$touch"
|
@blur="$v.login.$touch"
|
||||||
/>
|
/>
|
||||||
<woot-input
|
<woot-input
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import SettingsSection from 'dashboard/components/SettingsSection';
|
import SettingsSection from 'dashboard/components/SettingsSection';
|
||||||
import { required, minLength, email } from 'vuelidate/lib/validators';
|
import { required, minLength } from 'vuelidate/lib/validators';
|
||||||
import InputRadioGroup from './components/InputRadioGroup';
|
import InputRadioGroup from './components/InputRadioGroup';
|
||||||
import SingleSelectDropdown from './components/SingleSelectDropdown';
|
import SingleSelectDropdown from './components/SingleSelectDropdown';
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ export default {
|
||||||
isSMTPEnabled: false,
|
isSMTPEnabled: false,
|
||||||
address: '',
|
address: '',
|
||||||
port: '',
|
port: '',
|
||||||
email: '',
|
login: '',
|
||||||
password: '',
|
password: '',
|
||||||
domain: '',
|
domain: '',
|
||||||
ssl: false,
|
ssl: false,
|
||||||
|
@ -147,7 +147,7 @@ export default {
|
||||||
required,
|
required,
|
||||||
minLength: minLength(2),
|
minLength: minLength(2),
|
||||||
},
|
},
|
||||||
email: { required, email },
|
login: { required },
|
||||||
password: { required },
|
password: { required },
|
||||||
domain: { required },
|
domain: { required },
|
||||||
},
|
},
|
||||||
|
@ -168,7 +168,7 @@ export default {
|
||||||
smtp_enabled,
|
smtp_enabled,
|
||||||
smtp_address,
|
smtp_address,
|
||||||
smtp_port,
|
smtp_port,
|
||||||
smtp_email,
|
smtp_login,
|
||||||
smtp_password,
|
smtp_password,
|
||||||
smtp_domain,
|
smtp_domain,
|
||||||
smtp_enable_starttls_auto,
|
smtp_enable_starttls_auto,
|
||||||
|
@ -179,7 +179,7 @@ export default {
|
||||||
this.isSMTPEnabled = smtp_enabled;
|
this.isSMTPEnabled = smtp_enabled;
|
||||||
this.address = smtp_address;
|
this.address = smtp_address;
|
||||||
this.port = smtp_port;
|
this.port = smtp_port;
|
||||||
this.email = smtp_email;
|
this.login = smtp_login;
|
||||||
this.password = smtp_password;
|
this.password = smtp_password;
|
||||||
this.domain = smtp_domain;
|
this.domain = smtp_domain;
|
||||||
this.starttls = smtp_enable_starttls_auto;
|
this.starttls = smtp_enable_starttls_auto;
|
||||||
|
@ -220,7 +220,7 @@ export default {
|
||||||
smtp_enabled: this.isSMTPEnabled,
|
smtp_enabled: this.isSMTPEnabled,
|
||||||
smtp_address: this.address,
|
smtp_address: this.address,
|
||||||
smtp_port: this.port,
|
smtp_port: this.port,
|
||||||
smtp_email: this.email,
|
smtp_login: this.login,
|
||||||
smtp_password: this.password,
|
smtp_password: this.password,
|
||||||
smtp_domain: this.domain,
|
smtp_domain: this.domain,
|
||||||
smtp_enable_ssl_tls: this.ssl,
|
smtp_enable_ssl_tls: this.ssl,
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Inboxes::FetchImapEmailsJob < ApplicationJob
|
||||||
Mail.defaults do
|
Mail.defaults do
|
||||||
retriever_method :imap, address: channel.imap_address,
|
retriever_method :imap, address: channel.imap_address,
|
||||||
port: channel.imap_port,
|
port: channel.imap_port,
|
||||||
user_name: channel.imap_email,
|
user_name: channel.imap_login,
|
||||||
password: channel.imap_password,
|
password: channel.imap_password,
|
||||||
enable_ssl: channel.imap_enable_ssl
|
enable_ssl: channel.imap_enable_ssl
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,11 +128,11 @@ class ConversationReplyMailer < ApplicationMailer
|
||||||
def custom_message_id
|
def custom_message_id
|
||||||
last_message = @message || @messages&.last
|
last_message = @message || @messages&.last
|
||||||
|
|
||||||
"<conversation/#{@conversation.uuid}/messages/#{last_message&.id}@#{@account.inbound_email_domain}>"
|
"<conversation/#{@conversation.uuid}/messages/#{last_message&.id}@#{channel_email_domain}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def in_reply_to_email
|
def in_reply_to_email
|
||||||
conversation_reply_email_id || "<account/#{@account.id}/conversation/#{@conversation.uuid}@#{@account.inbound_email_domain}>"
|
conversation_reply_email_id || "<account/#{@account.id}/conversation/#{@conversation.uuid}@#{channel_email_domain}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def conversation_reply_email_id
|
def conversation_reply_email_id
|
||||||
|
|
|
@ -26,7 +26,7 @@ module ConversationReplyMailerHelper
|
||||||
smtp_settings = {
|
smtp_settings = {
|
||||||
address: @channel.smtp_address,
|
address: @channel.smtp_address,
|
||||||
port: @channel.smtp_port,
|
port: @channel.smtp_port,
|
||||||
user_name: @channel.smtp_email,
|
user_name: @channel.smtp_login,
|
||||||
password: @channel.smtp_password,
|
password: @channel.smtp_password,
|
||||||
domain: @channel.smtp_domain,
|
domain: @channel.smtp_domain,
|
||||||
tls: @channel.smtp_enable_ssl_tls,
|
tls: @channel.smtp_enable_ssl_tls,
|
||||||
|
@ -48,10 +48,18 @@ module ConversationReplyMailerHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_from
|
def email_from
|
||||||
email_smtp_enabled ? @channel.smtp_email : from_email_with_name
|
email_smtp_enabled ? @channel.email : from_email_with_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_reply_to
|
def email_reply_to
|
||||||
email_imap_enabled ? @channel.imap_email : reply_email
|
email_imap_enabled ? @channel.email : reply_email
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use channel email domain in case of account email domain is not set for custom message_id and in_reply_to
|
||||||
|
def channel_email_domain
|
||||||
|
return @account.inbound_email_domain if @account.inbound_email_domain.present?
|
||||||
|
|
||||||
|
email = @inbox.channel.try(:email)
|
||||||
|
email.present? ? email.split('@').last : raise(StandardError, 'Channel email domain not present.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,19 +6,19 @@
|
||||||
# email :string not null
|
# email :string not null
|
||||||
# forward_to_email :string not null
|
# forward_to_email :string not null
|
||||||
# imap_address :string default("")
|
# imap_address :string default("")
|
||||||
# imap_email :string default("")
|
|
||||||
# imap_enable_ssl :boolean default(TRUE)
|
# imap_enable_ssl :boolean default(TRUE)
|
||||||
# imap_enabled :boolean default(FALSE)
|
# imap_enabled :boolean default(FALSE)
|
||||||
# imap_inbox_synced_at :datetime
|
# imap_inbox_synced_at :datetime
|
||||||
|
# imap_login :string default("")
|
||||||
# imap_password :string default("")
|
# imap_password :string default("")
|
||||||
# imap_port :integer default(0)
|
# imap_port :integer default(0)
|
||||||
# smtp_address :string default("")
|
# smtp_address :string default("")
|
||||||
# smtp_authentication :string default("login")
|
# smtp_authentication :string default("login")
|
||||||
# smtp_domain :string default("")
|
# smtp_domain :string default("")
|
||||||
# smtp_email :string default("")
|
|
||||||
# smtp_enable_ssl_tls :boolean default(FALSE)
|
# smtp_enable_ssl_tls :boolean default(FALSE)
|
||||||
# smtp_enable_starttls_auto :boolean default(TRUE)
|
# smtp_enable_starttls_auto :boolean default(TRUE)
|
||||||
# smtp_enabled :boolean default(FALSE)
|
# smtp_enabled :boolean default(FALSE)
|
||||||
|
# smtp_login :string default("")
|
||||||
# smtp_openssl_verify_mode :string default("none")
|
# smtp_openssl_verify_mode :string default("none")
|
||||||
# smtp_password :string default("")
|
# smtp_password :string default("")
|
||||||
# smtp_port :integer default(0)
|
# smtp_port :integer default(0)
|
||||||
|
@ -37,8 +37,8 @@ class Channel::Email < ApplicationRecord
|
||||||
include Reauthorizable
|
include Reauthorizable
|
||||||
|
|
||||||
self.table_name = 'channel_email'
|
self.table_name = 'channel_email'
|
||||||
EDITABLE_ATTRS = [:email, :imap_enabled, :imap_email, :imap_password, :imap_address, :imap_port, :imap_enable_ssl, :imap_inbox_synced_at,
|
EDITABLE_ATTRS = [:email, :imap_enabled, :imap_login, :imap_password, :imap_address, :imap_port, :imap_enable_ssl, :imap_inbox_synced_at,
|
||||||
:smtp_enabled, :smtp_email, :smtp_password, :smtp_address, :smtp_port, :smtp_domain, :smtp_enable_starttls_auto,
|
:smtp_enabled, :smtp_login, :smtp_password, :smtp_address, :smtp_port, :smtp_domain, :smtp_enable_starttls_auto,
|
||||||
:smtp_enable_ssl_tls, :smtp_openssl_verify_mode, :smtp_authentication].freeze
|
:smtp_enable_ssl_tls, :smtp_openssl_verify_mode, :smtp_authentication].freeze
|
||||||
|
|
||||||
validates :email, uniqueness: true
|
validates :email, uniqueness: true
|
||||||
|
|
|
@ -53,7 +53,7 @@ if resource.email?
|
||||||
json.email resource.channel.try(:email)
|
json.email resource.channel.try(:email)
|
||||||
|
|
||||||
## IMAP
|
## IMAP
|
||||||
json.imap_email resource.channel.try(:imap_email)
|
json.imap_login resource.channel.try(:imap_login)
|
||||||
json.imap_password resource.channel.try(:imap_password)
|
json.imap_password resource.channel.try(:imap_password)
|
||||||
json.imap_address resource.channel.try(:imap_address)
|
json.imap_address resource.channel.try(:imap_address)
|
||||||
json.imap_port resource.channel.try(:imap_port)
|
json.imap_port resource.channel.try(:imap_port)
|
||||||
|
@ -61,7 +61,7 @@ if resource.email?
|
||||||
json.imap_enable_ssl resource.channel.try(:imap_enable_ssl)
|
json.imap_enable_ssl resource.channel.try(:imap_enable_ssl)
|
||||||
|
|
||||||
## SMTP
|
## SMTP
|
||||||
json.smtp_email resource.channel.try(:smtp_email)
|
json.smtp_login resource.channel.try(:smtp_login)
|
||||||
json.smtp_password resource.channel.try(:smtp_password)
|
json.smtp_password resource.channel.try(:smtp_password)
|
||||||
json.smtp_address resource.channel.try(:smtp_address)
|
json.smtp_address resource.channel.try(:smtp_address)
|
||||||
json.smtp_port resource.channel.try(:smtp_port)
|
json.smtp_port resource.channel.try(:smtp_port)
|
||||||
|
|
|
@ -16,6 +16,6 @@ trigger_scheduled_items_job:
|
||||||
|
|
||||||
# executed At every 5th minute..
|
# executed At every 5th minute..
|
||||||
trigger_imap_email_inboxes_job:
|
trigger_imap_email_inboxes_job:
|
||||||
cron: '*/5 * * * *'
|
cron: '*/1 * * * *'
|
||||||
class: 'Inboxes::FetchImapEmailInboxesJob'
|
class: 'Inboxes::FetchImapEmailInboxesJob'
|
||||||
queue: scheduled_jobs
|
queue: scheduled_jobs
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class RenameImapEmailAndSmtpEmailColumns < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
rename_column :channel_email, :imap_email, :imap_login
|
||||||
|
rename_column :channel_email, :smtp_email, :smtp_login
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_04_05_092033) do
|
ActiveRecord::Schema.define(version: 2022_04_09_044943) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
|
@ -190,14 +190,14 @@ ActiveRecord::Schema.define(version: 2022_04_05_092033) do
|
||||||
t.boolean "imap_enabled", default: false
|
t.boolean "imap_enabled", default: false
|
||||||
t.string "imap_address", default: ""
|
t.string "imap_address", default: ""
|
||||||
t.integer "imap_port", default: 0
|
t.integer "imap_port", default: 0
|
||||||
t.string "imap_email", default: ""
|
t.string "imap_login", default: ""
|
||||||
t.string "imap_password", default: ""
|
t.string "imap_password", default: ""
|
||||||
t.boolean "imap_enable_ssl", default: true
|
t.boolean "imap_enable_ssl", default: true
|
||||||
t.datetime "imap_inbox_synced_at"
|
t.datetime "imap_inbox_synced_at"
|
||||||
t.boolean "smtp_enabled", default: false
|
t.boolean "smtp_enabled", default: false
|
||||||
t.string "smtp_address", default: ""
|
t.string "smtp_address", default: ""
|
||||||
t.integer "smtp_port", default: 0
|
t.integer "smtp_port", default: 0
|
||||||
t.string "smtp_email", default: ""
|
t.string "smtp_login", default: ""
|
||||||
t.string "smtp_password", default: ""
|
t.string "smtp_password", default: ""
|
||||||
t.string "smtp_domain", default: ""
|
t.string "smtp_domain", default: ""
|
||||||
t.boolean "smtp_enable_starttls_auto", default: true
|
t.boolean "smtp_enable_starttls_auto", default: true
|
||||||
|
|
|
@ -426,7 +426,7 @@ RSpec.describe 'Inboxes API', type: :request do
|
||||||
imap_enabled: true,
|
imap_enabled: true,
|
||||||
imap_address: 'imap.gmail.com',
|
imap_address: 'imap.gmail.com',
|
||||||
imap_port: 993,
|
imap_port: 993,
|
||||||
imap_email: 'imaptest@gmail.com'
|
imap_login: 'imaptest@gmail.com'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
as: :json
|
as: :json
|
||||||
|
@ -496,7 +496,7 @@ RSpec.describe 'Inboxes API', type: :request do
|
||||||
smtp_enabled: true,
|
smtp_enabled: true,
|
||||||
smtp_address: 'smtp.gmail.com',
|
smtp_address: 'smtp.gmail.com',
|
||||||
smtp_port: 587,
|
smtp_port: 587,
|
||||||
smtp_email: 'smtptest@gmail.com',
|
smtp_login: 'smtptest@gmail.com',
|
||||||
smtp_enable_starttls_auto: true,
|
smtp_enable_starttls_auto: true,
|
||||||
smtp_openssl_verify_mode: 'peer'
|
smtp_openssl_verify_mode: 'peer'
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ RSpec.describe 'Inboxes API', type: :request do
|
||||||
channel: {
|
channel: {
|
||||||
smtp_enabled: true,
|
smtp_enabled: true,
|
||||||
smtp_address: 'smtp.gmail.com',
|
smtp_address: 'smtp.gmail.com',
|
||||||
smtp_email: 'smtptest@gmail.com',
|
smtp_login: 'smtptest@gmail.com',
|
||||||
smtp_port: 587,
|
smtp_port: 587,
|
||||||
smtp_enable_ssl_tls: true,
|
smtp_enable_ssl_tls: true,
|
||||||
smtp_openssl_verify_mode: 'none'
|
smtp_openssl_verify_mode: 'none'
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
||||||
RSpec.describe Inboxes::FetchImapEmailInboxesJob, type: :job do
|
RSpec.describe Inboxes::FetchImapEmailInboxesJob, type: :job do
|
||||||
let(:account) { create(:account) }
|
let(:account) { create(:account) }
|
||||||
let(:imap_email_channel) do
|
let(:imap_email_channel) do
|
||||||
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com', imap_port: 993, imap_email: 'imap@gmail.com',
|
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com', imap_port: 993, imap_login: 'imap@gmail.com',
|
||||||
imap_password: 'password', account: account)
|
imap_password: 'password', account: account)
|
||||||
end
|
end
|
||||||
let(:email_inbox) { create(:inbox, channel: imap_email_channel, account: account) }
|
let(:email_inbox) { create(:inbox, channel: imap_email_channel, account: account) }
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
||||||
RSpec.describe Inboxes::FetchImapEmailsJob, type: :job do
|
RSpec.describe Inboxes::FetchImapEmailsJob, type: :job do
|
||||||
let(:account) { create(:account) }
|
let(:account) { create(:account) }
|
||||||
let(:imap_email_channel) do
|
let(:imap_email_channel) do
|
||||||
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com', imap_port: 993, imap_email: 'imap@gmail.com',
|
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com', imap_port: 993, imap_login: 'imap@gmail.com',
|
||||||
imap_password: 'password', imap_inbox_synced_at: Time.now.utc - 10, account: account)
|
imap_password: 'password', imap_inbox_synced_at: Time.now.utc - 10, account: account)
|
||||||
end
|
end
|
||||||
let(:email_inbox) { create(:inbox, channel: imap_email_channel, account: account) }
|
let(:email_inbox) { create(:inbox, channel: imap_email_channel, account: account) }
|
||||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Imap::ImapMailbox, type: :mailbox do
|
||||||
let(:agent) { create(:user, email: 'agent@example.com', account: account) }
|
let(:agent) { create(:user, email: 'agent@example.com', account: account) }
|
||||||
let(:channel) do
|
let(:channel) do
|
||||||
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com',
|
create(:channel_email, imap_enabled: true, imap_address: 'imap.gmail.com',
|
||||||
imap_port: 993, imap_email: 'imap@gmail.com', imap_password: 'password',
|
imap_port: 993, imap_login: 'imap@gmail.com', imap_password: 'password',
|
||||||
account: account)
|
account: account)
|
||||||
end
|
end
|
||||||
let(:inbox) { create(:inbox, channel: channel, account: account) }
|
let(:inbox) { create(:inbox, channel: channel, account: account) }
|
||||||
|
|
|
@ -156,7 +156,7 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
||||||
|
|
||||||
context 'when smtp enabled for email channel' do
|
context 'when smtp enabled for email channel' do
|
||||||
let(:smtp_email_channel) do
|
let(:smtp_email_channel) do
|
||||||
create(:channel_email, smtp_enabled: true, smtp_address: 'smtp.gmail.com', smtp_port: 587, smtp_email: 'smtp@gmail.com',
|
create(:channel_email, smtp_enabled: true, smtp_address: 'smtp.gmail.com', smtp_port: 587, smtp_login: 'smtp@gmail.com',
|
||||||
smtp_password: 'password', smtp_domain: 'smtp.gmail.com', account: account)
|
smtp_password: 'password', smtp_domain: 'smtp.gmail.com', account: account)
|
||||||
end
|
end
|
||||||
let(:conversation) { create(:conversation, assignee: agent, inbox: smtp_email_channel.inbox, account: account).reload }
|
let(:conversation) { create(:conversation, assignee: agent, inbox: smtp_email_channel.inbox, account: account).reload }
|
||||||
|
@ -251,5 +251,24 @@ RSpec.describe ConversationReplyMailer, type: :mailer do
|
||||||
expect(mail.in_reply_to).to eq("account/#{conversation.account.id}/conversation/#{conversation.uuid}@#{conversation.account.domain}")
|
expect(mail.in_reply_to).to eq("account/#{conversation.account.id}/conversation/#{conversation.uuid}@#{conversation.account.domain}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when inbound email domain is not enabled' do
|
||||||
|
let(:new_account) { create(:account, domain: nil) }
|
||||||
|
let!(:email_channel) { create(:channel_email, account: new_account) }
|
||||||
|
let!(:inbox) { create(:inbox, channel: email_channel, account: new_account) }
|
||||||
|
let(:inbox_member) { create(:inbox_member, user: agent, inbox: inbox) }
|
||||||
|
let(:conversation) { create(:conversation, assignee: agent, inbox: inbox_member.inbox, account: new_account) }
|
||||||
|
let!(:message) { create(:message, conversation: conversation, account: new_account) }
|
||||||
|
let(:mail) { described_class.reply_with_summary(message.conversation, message.id).deliver_now }
|
||||||
|
let(:domain) { inbox.channel.email.split('@').last }
|
||||||
|
|
||||||
|
it 'sets the correct custom message id' do
|
||||||
|
expect(mail.message_id).to eq("conversation/#{conversation.uuid}/messages/#{message.id}@#{domain}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets the correct in reply to id' do
|
||||||
|
expect(mail.in_reply_to).to eq("account/#{conversation.account.id}/conversation/#{conversation.uuid}@#{domain}")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue