Feature: Send attachments to widget user (#621)

This commit is contained in:
Nithin David Thomas
2020-03-22 15:54:36 +05:30
committed by GitHub
parent fe70843fae
commit f7e5f1fabf
16 changed files with 317 additions and 92 deletions

View File

@@ -15,8 +15,6 @@
# message_id :integer not null
#
require 'uri'
require 'open-uri'
class Attachment < ApplicationRecord
include Rails.application.routes.url_helpers
belongs_to :account
@@ -38,7 +36,7 @@ class Attachment < ApplicationRecord
{
extension: extension,
data_url: file_url,
thumb_url: file.try(:thumb).try(:url) # will exist only for images
thumb_url: thumb_url
}
end
@@ -70,4 +68,12 @@ class Attachment < ApplicationRecord
def file_url
file.attached? ? url_for(file) : ''
end
def thumb_url
if file.attached? && file.representable?
url_for(file.representation(resize: '250x250'))
else
''
end
end
end