diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee index 8fa3a7054..4738e61ad 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee @@ -120,6 +120,17 @@ class ArticleViewItem extends App.ObserverController article['html'] = App.Utils.text2html(body) article['html'] = article['html'].replace(signatureDetected, '') + # check if email link need to be updated + if article.type.name is 'email' + if !article.preferences.links + article.preferences.links = [ + { + name: 'Raw' + url: "#{@Config.get('api_path')}/ticket_article_plain/#{article.id}" + target: '_blank' + } + ] + if article.preferences.delivery_message @html App.view('ticket_zoom/article_view_delivery_failed')( ticket: @ticket diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco index 4ec147742..cc367e43f 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco @@ -28,7 +28,6 @@ -
<% if @article.sender.name isnt 'Agent': %> <% position = 'left' %> @@ -46,7 +45,7 @@
<%- @T('See more') %>
- <% if !_.isEmpty( @article.attachments ): %> + <% if !_.isEmpty(@article.attachments): %>
<%- @Icon('paperclip') %>
<%- @article.attachments.length %> <%- @T('Attached Files') %>
@@ -62,7 +61,6 @@
-
diff --git a/app/models/channel/driver/facebook.rb b/app/models/channel/driver/facebook.rb index 9fe8b50dd..62320b31d 100644 --- a/app/models/channel/driver/facebook.rb +++ b/app/models/channel/driver/facebook.rb @@ -86,7 +86,7 @@ class Channel::Driver::Facebook next if page_to_sync_params['group_id'].empty? page_client = Facebook.new(page['access_token']) - posts = page_client.client.get_connection('me', 'feed', fields: 'id,from,to,message,created_time,comments') + posts = page_client.client.get_connection('me', 'feed', fields: 'id,from,to,message,created_time,permalink_url,comments{id,from,to,message,created_time}') posts.each { |post| # ignore older messages diff --git a/lib/facebook.rb b/lib/facebook.rb index 4793ca4f9..bded96b63 100644 --- a/lib/facebook.rb +++ b/lib/facebook.rb @@ -210,8 +210,7 @@ result end state = get_state(page, post) - - Ticket.create( + Ticket.create!( customer_id: user.id, title: title, group_id: group_id, @@ -220,6 +219,9 @@ result preferences: { channel_id: channel.id, channel_fb_object_id: page['id'], + facebook: { + permalink_url: post['permalink_url'], + } }, ) end @@ -260,6 +262,11 @@ result articles += nested_comments(post['comments']['data'], post['id']) end + base_url = nil + if ticket.preferences['facebook'] && ticket.preferences['facebook']['permalink_url'] + base_url = ticket.preferences['facebook']['permalink_url'] + end + articles.each { |article| next if Ticket::Article.find_by(message_id: article[:message_id]) @@ -270,6 +277,22 @@ result ticket.save! end + links = [] + if base_url + url = base_url + realtive_id = article[:message_id].split('_')[1] + if realtive_id + url += "?comment_id=#{realtive_id}" + end + links = [ + { + url: url, + target: '_blank', + name: 'on Facebook', + }, + ] + end + article = { #to: @account['name'], ticket_id: ticket.id, @@ -277,6 +300,9 @@ result sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id, created_by_id: 1, updated_by_id: 1, + preferences: { + links: links, + }, }.merge(article) Ticket::Article.create(article) } @@ -363,7 +389,7 @@ result in_reply_to: in_reply_to } result.push(article_data) - sub_comments = @client.get_object("#{comment['id']}/comments") + sub_comments = @client.get_object("#{comment['id']}/comments", fields: 'id,from,to,message,created_time') sub_articles = nested_comments(sub_comments, comment['id']) result += sub_articles } diff --git a/lib/tweet_base.rb b/lib/tweet_base.rb index 8b7b32ead..d7677065b 100644 --- a/lib/tweet_base.rb +++ b/lib/tweet_base.rb @@ -208,7 +208,7 @@ class TweetBase ticket.save! end - Ticket::Article.create( + Ticket::Article.create!( from: from, to: to, body: tweet.text,