fix: Automatically remove expired story mention (#5300)

When a user mentions the connected Instagram page in a story, the story's content is downloaded in Chatwoot, then if the user deletes the story, the content persists in the platform.

fixes: #5258
This commit is contained in:
Tejaswini Chile
2022-12-08 18:25:24 +05:30
committed by GitHub
parent 431e2931c4
commit 7dc790a7e0
13 changed files with 111 additions and 15 deletions

View File

@@ -6,5 +6,9 @@ FactoryBot.define do
user_access_token { SecureRandom.uuid }
page_id { SecureRandom.uuid }
account
before :create do |_channel|
WebMock::API.stub_request(:post, 'https://graph.facebook.com/v3.2/me/subscribed_apps')
end
end
end

View File

@@ -8,6 +8,18 @@ FactoryBot.define do
content_type { 'text' }
account { create(:account) }
trait :instagram_story_mention do
content_attributes { { image_type: 'story_mention' } }
after(:build) do |message|
unless message.inbox.instagram?
message.inbox = create(:inbox, account: message.account,
channel: create(:channel_instagram_fb_page, account: message.account, instagram_id: 'instagram-123'))
end
attachment = message.attachments.new(account_id: message.account_id, file_type: :image, external_url: 'https://www.example.com/test.jpeg')
attachment.file.attach(io: File.open(Rails.root.join('spec/assets/avatar.png')), filename: 'avatar.png', content_type: 'image/png')
end
end
after(:build) do |message|
message.sender ||= message.outgoing? ? create(:user, account: message.account) : create(:contact, account: message.account)
message.inbox ||= message.conversation&.inbox || create(:inbox, account: message.account)