2017-11-21 21:50:03 +00:00
|
|
|
FactoryBot.define do
|
2019-01-22 16:35:01 +00:00
|
|
|
factory :'ticket/article', aliases: %i[ticket_article] do
|
2020-09-11 07:25:47 +00:00
|
|
|
inbound_email
|
2018-12-13 09:06:44 +00:00
|
|
|
|
2020-06-22 09:57:45 +00:00
|
|
|
association :ticket, strategy: :create # or else build(:ticket_article).save fails
|
2019-02-10 12:24:22 +00:00
|
|
|
from { 'factory-customer-1@example.com' }
|
|
|
|
to { 'factory-customer-1@example.com' }
|
|
|
|
subject { 'factory article' }
|
|
|
|
message_id { 'factory@id_com_1' }
|
|
|
|
body { 'some message 123' }
|
|
|
|
internal { false }
|
|
|
|
sender { Ticket::Article::Sender.find_by(name: sender_name) }
|
|
|
|
type { Ticket::Article::Type.find_by(name: type_name) }
|
|
|
|
updated_by_id { 1 }
|
|
|
|
created_by_id { 1 }
|
2018-12-13 09:06:44 +00:00
|
|
|
|
2020-09-11 07:25:47 +00:00
|
|
|
trait :inbound_email do
|
|
|
|
transient do
|
|
|
|
type_name { 'email' }
|
|
|
|
sender_name { 'Customer' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :outbound_email do
|
|
|
|
transient do
|
|
|
|
type_name { 'email' }
|
|
|
|
sender_name { 'Agent' }
|
|
|
|
end
|
|
|
|
|
|
|
|
from { ticket.group.name }
|
|
|
|
to { "#{ticket.customer.fullname} <#{ticket.customer.email}>" }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :inbound_phone do
|
|
|
|
transient do
|
|
|
|
type_name { 'phone' }
|
|
|
|
sender_name { 'Customer' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :outbound_phone do
|
|
|
|
transient do
|
|
|
|
type_name { 'phone' }
|
|
|
|
sender_name { 'Agent' }
|
|
|
|
end
|
|
|
|
|
|
|
|
from { nil }
|
|
|
|
to { ticket.customer.fullname }
|
|
|
|
end
|
|
|
|
|
2018-12-13 09:06:44 +00:00
|
|
|
factory :twitter_article do
|
|
|
|
transient do
|
2019-02-10 12:24:22 +00:00
|
|
|
type_name { 'twitter status' }
|
2018-12-13 09:06:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
association :ticket, factory: :twitter_ticket
|
Fixes #2715 - Twitter status URLs are broken
This commit is a complement of its parent:
the parent fixes broken links to Twitter DMs,
while this one fixes broken links to Twitter statuses.
When importing tweets (articles of type "twitter status"),
Zammad generates a source link URL using the following format:
https://twitter.com/statuses/:id
and then stores that URL under `article.preferences[:links]`.
This URL template worked until as recently as 2017[0],
but currently fails for users actively logged in to Twitter.
Now, the correct URL template appears to be
https://twitter.com/:user_id/status/:id
where `:user_id` is not strict, and may be any word (\w+) <= 20 chars.
Try it yourself:
$ curl https://twitter.com/elonmusk/status/1069382411899817990
<html><body>You are being <a href="https://twitter.com/medenhofer/status/1069382411899817990">redirected</a>.</body></html>
In this commit, we replace `:user_id` with a single underscore (`_`).
This behavior is not officially documented anywhere (as far as I know),
but it works (for now).
This commit also extends the previous commit's DB migration/bg job
to rectify existing, broken tweet URLs stored in the database.
For performance purposes, this migration is performed in the background
and limited to the latest 10,000 Twitter articles.
[0]: https://stackoverflow.com/questions/41786123
GitHub: https://github.com/zammad/zammad/issues/2715
2019-11-14 06:03:34 +00:00
|
|
|
message_id { '775410014383026176' }
|
2018-12-13 09:06:44 +00:00
|
|
|
body { Faker::Lorem.sentence }
|
2020-02-25 08:55:34 +00:00
|
|
|
sender_name { 'Agent' }
|
2020-02-21 04:43:51 +00:00
|
|
|
|
|
|
|
trait :reply do
|
2020-06-22 09:57:45 +00:00
|
|
|
in_reply_to { Faker::Number.number(19) }
|
2020-02-21 04:43:51 +00:00
|
|
|
end
|
2018-12-13 09:06:44 +00:00
|
|
|
end
|
2019-11-07 10:01:58 +00:00
|
|
|
|
|
|
|
factory :twitter_dm_article do
|
|
|
|
transient do
|
|
|
|
type_name { 'twitter direct-message' }
|
|
|
|
end
|
|
|
|
|
|
|
|
association :ticket, factory: :twitter_ticket
|
|
|
|
body { Faker::Lorem.sentence }
|
2020-02-21 04:42:25 +00:00
|
|
|
|
|
|
|
trait :pending_delivery do
|
|
|
|
transient do
|
|
|
|
recipient { create(:twitter_authorization) }
|
|
|
|
sender_id { Faker::Number.number(10) }
|
|
|
|
end
|
|
|
|
|
2020-02-21 04:43:51 +00:00
|
|
|
from { ticket.owner.fullname }
|
2020-02-21 04:42:25 +00:00
|
|
|
to { recipient.username }
|
|
|
|
in_reply_to { Faker::Number.number(19) }
|
|
|
|
content_type { 'text/plain' }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :delivered do
|
|
|
|
pending_delivery
|
|
|
|
message_id { Faker::Number.number(19) }
|
|
|
|
preferences do
|
|
|
|
{
|
|
|
|
delivery_retry: 1,
|
|
|
|
twitter: {
|
|
|
|
recipient_id: recipient.uid,
|
|
|
|
sender_id: sender_id
|
|
|
|
},
|
|
|
|
links: [
|
|
|
|
{
|
|
|
|
url: "https://twitter.com/messages/#{recipient.uid}-#{sender_id}",
|
|
|
|
target: '_blank',
|
|
|
|
name: 'on Twitter'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
delivery_status_message: nil,
|
|
|
|
delivery_status: 'success',
|
|
|
|
delivery_status_date: Time.current
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2019-11-07 10:01:58 +00:00
|
|
|
end
|
2017-05-05 09:16:47 +00:00
|
|
|
end
|
|
|
|
end
|