2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-04-24 13:26:09 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :channel do
|
2019-03-27 09:01:36 +00:00
|
|
|
area { 'Email::Dummy' }
|
|
|
|
group { ::Group.find(1) }
|
|
|
|
active { true }
|
2020-11-05 16:31:00 +00:00
|
|
|
options { nil }
|
|
|
|
preferences { nil }
|
2019-03-27 09:01:36 +00:00
|
|
|
updated_by_id { 1 }
|
|
|
|
created_by_id { 1 }
|
2018-12-13 09:06:44 +00:00
|
|
|
|
2019-01-15 13:11:57 +00:00
|
|
|
factory :email_channel do
|
2019-03-27 09:01:36 +00:00
|
|
|
area { 'Email::Account' }
|
2019-01-15 13:11:57 +00:00
|
|
|
options do
|
|
|
|
{
|
2020-11-20 10:54:09 +00:00
|
|
|
inbound: inbound,
|
|
|
|
outbound: outbound,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
transient do
|
|
|
|
inbound do
|
|
|
|
{
|
2019-01-15 13:11:57 +00:00
|
|
|
adapter: 'null', options: {}
|
2020-11-20 10:54:09 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
outbound do
|
|
|
|
{
|
2019-01-15 13:11:57 +00:00
|
|
|
adapter: 'sendmail'
|
|
|
|
}
|
2020-11-20 10:54:09 +00:00
|
|
|
end
|
2019-01-15 13:11:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 09:06:44 +00:00
|
|
|
factory :twitter_channel do
|
2019-03-27 09:01:36 +00:00
|
|
|
area { 'Twitter::Account' }
|
2018-12-13 09:06:44 +00:00
|
|
|
options do
|
|
|
|
{
|
2020-02-17 10:37:36 +00:00
|
|
|
adapter: 'twitter',
|
|
|
|
user: {
|
|
|
|
id: oauth_token&.split('-')&.first,
|
|
|
|
screen_name: 'nicole_braun',
|
|
|
|
name: 'Nicole Braun',
|
2018-12-13 09:06:44 +00:00
|
|
|
},
|
2020-02-17 10:37:36 +00:00
|
|
|
auth: {
|
|
|
|
external_credential_id: external_credential.id,
|
|
|
|
oauth_token: oauth_token,
|
|
|
|
oauth_token_secret: oauth_token_secret,
|
2018-12-13 09:06:44 +00:00
|
|
|
},
|
2020-02-17 10:37:36 +00:00
|
|
|
sync: {
|
|
|
|
webhook_id: '',
|
|
|
|
mentions: {
|
|
|
|
group_id: Group.first.id
|
|
|
|
},
|
|
|
|
direct_messages: {
|
|
|
|
group_id: Group.first.id
|
|
|
|
},
|
|
|
|
search: [
|
2018-12-13 09:06:44 +00:00
|
|
|
{
|
2020-03-12 18:28:50 +00:00
|
|
|
term: search_term,
|
2018-12-18 10:40:56 +00:00
|
|
|
group_id: Group.first.id
|
2018-12-13 09:06:44 +00:00
|
|
|
},
|
|
|
|
],
|
2020-02-17 10:37:36 +00:00
|
|
|
},
|
|
|
|
subscribed_to_webhook_id: external_credential.credentials[:webhook_id],
|
2018-12-18 10:40:56 +00:00
|
|
|
}.deep_merge(custom_options)
|
2018-12-13 09:06:44 +00:00
|
|
|
end
|
2020-02-17 10:37:36 +00:00
|
|
|
|
|
|
|
transient do
|
|
|
|
custom_options { {} }
|
|
|
|
external_credential { create(:twitter_credential) }
|
|
|
|
oauth_token { external_credential.credentials[:oauth_token] }
|
|
|
|
oauth_token_secret { external_credential.credentials[:oauth_token_secret] }
|
2020-03-12 18:28:50 +00:00
|
|
|
search_term { 'zammad' }
|
2020-02-17 10:37:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :legacy do
|
|
|
|
transient do
|
|
|
|
custom_options { { sync: { import_older_tweets: true } } }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :invalid do
|
|
|
|
transient do
|
|
|
|
external_credential { create(:twitter_credential, :invalid) }
|
|
|
|
end
|
|
|
|
end
|
2018-12-13 09:06:44 +00:00
|
|
|
end
|
2020-11-20 10:52:37 +00:00
|
|
|
|
2021-03-16 15:24:09 +00:00
|
|
|
factory :facebook_channel do
|
|
|
|
area { 'Facebook::Account' }
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
adapter: 'facebook',
|
|
|
|
user: {
|
|
|
|
id: ENV['FACEBOOK_ADMIN_USER_ID'],
|
|
|
|
name: "#{ENV['FACEBOOK_ADMIN_FIRSTNAME']} #{ENV['FACEBOOK_ADMIN_LASTNAME']}",
|
|
|
|
},
|
|
|
|
auth: {
|
|
|
|
access_token: ENV['FACEBOOK_ADMIN_ACCESS_TOKEN'],
|
|
|
|
},
|
|
|
|
sync: {
|
|
|
|
pages: {
|
|
|
|
ENV['FACEBOOK_PAGE_1_ID'] => {
|
|
|
|
group_id: Group.first.id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pages: [
|
|
|
|
{
|
|
|
|
id: ENV['FACEBOOK_PAGE_1_ID'],
|
|
|
|
name: ENV['FACEBOOK_PAGE_1_NAME'],
|
|
|
|
access_token: ENV['FACEBOOK_PAGE_1_ACCCESS_TOKEN'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: ENV['FACEBOOK_PAGE_2_ID'],
|
|
|
|
name: ENV['FACEBOOK_PAGE_2_NAME'],
|
|
|
|
access_token: ENV['FACEBOOK_PAGE_2_ACCCESS_TOKEN'],
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-20 10:52:37 +00:00
|
|
|
factory :google_channel do
|
|
|
|
area { 'Google::Account' }
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
'inbound' => {
|
|
|
|
'adapter' => 'imap',
|
|
|
|
'options' => {
|
|
|
|
'auth_type' => 'XOAUTH2',
|
|
|
|
'host' => 'imap.gmail.com',
|
2022-03-03 09:04:12 +00:00
|
|
|
'ssl' => 'ssl',
|
2020-11-20 10:52:37 +00:00
|
|
|
'user' => ENV['GMAIL_USER'],
|
|
|
|
'folder' => '',
|
|
|
|
'keep_on_server' => false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'outbound' => {
|
|
|
|
'adapter' => 'smtp',
|
|
|
|
'options' => {
|
|
|
|
'host' => 'smtp.gmail.com',
|
|
|
|
'port' => 465,
|
|
|
|
'ssl' => true,
|
|
|
|
'user' => ENV['GMAIL_USER'],
|
|
|
|
'authentication' => 'xoauth2',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'auth' => {
|
|
|
|
'type' => 'XOAUTH2',
|
|
|
|
'provider' => 'google',
|
|
|
|
'access_token' => 'xxx',
|
|
|
|
'expires_in' => 3599,
|
|
|
|
'refresh_token' => ENV['GMAIL_REFRESH_TOKEN'],
|
|
|
|
'scope' => 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://mail.google.com/ openid',
|
|
|
|
'token_type' => 'Bearer',
|
|
|
|
'id_token' => 'xxx',
|
|
|
|
'created_at' => 30.days.ago,
|
|
|
|
'client_id' => ENV['GMAIL_CLIENT_ID'],
|
|
|
|
'client_secret' => ENV['GMAIL_CLIENT_SECRET'],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :microsoft365_channel do
|
|
|
|
area { 'Microsoft365::Account' }
|
|
|
|
options do
|
|
|
|
{
|
|
|
|
'inbound' => {
|
|
|
|
'adapter' => 'imap',
|
|
|
|
'options' => {
|
|
|
|
'auth_type' => 'XOAUTH2',
|
|
|
|
'host' => 'outlook.office365.com',
|
2022-03-03 09:04:12 +00:00
|
|
|
'ssl' => 'ssl',
|
2020-11-20 10:52:37 +00:00
|
|
|
'user' => ENV['MICROSOFT365_USER'],
|
|
|
|
'folder' => '',
|
|
|
|
'keep_on_server' => false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'outbound' => {
|
|
|
|
'adapter' => 'smtp',
|
|
|
|
'options' => {
|
|
|
|
'host' => 'smtp.office365.com',
|
|
|
|
'port' => 587,
|
|
|
|
'user' => ENV['MICROSOFT365_USER'],
|
|
|
|
'authentication' => 'xoauth2',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'auth' => {
|
|
|
|
'type' => 'XOAUTH2',
|
|
|
|
'provider' => 'microsoft365',
|
|
|
|
'access_token' => 'xxx',
|
|
|
|
'expires_in' => 3599,
|
|
|
|
'refresh_token' => ENV['MICROSOFT365_REFRESH_TOKEN'],
|
|
|
|
'scope' => 'https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send offline_access openid profile email',
|
|
|
|
'token_type' => 'Bearer',
|
|
|
|
'id_token' => 'xxx',
|
|
|
|
'created_at' => 30.days.ago,
|
|
|
|
'client_id' => ENV['MICROSOFT365_CLIENT_ID'],
|
|
|
|
'client_secret' => ENV['MICROSOFT365_CLIENT_SECRET'],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2018-04-24 13:26:09 +00:00
|
|
|
end
|
|
|
|
end
|