Fixed issue#317 - Display origin url from tweet/facebook post.

This commit is contained in:
Martin Edenhofer 2016-10-28 16:59:15 +02:00
parent d74444fc30
commit f8a75f02b8
5 changed files with 47 additions and 10 deletions

View file

@ -120,6 +120,17 @@ class ArticleViewItem extends App.ObserverController
article['html'] = App.Utils.text2html(body)
article['html'] = article['html'].replace(signatureDetected, '<span class="js-signatureMarker"></span>')
# 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

View file

@ -28,7 +28,6 @@
</div>
</div>
</div>
<div class="article-content">
<% if @article.sender.name isnt 'Agent': %>
<% position = 'left' %>
@ -46,7 +45,7 @@
<div class="btn btn--text js-unfold"><%- @T('See more') %></div>
</div>
</div>
<% if !_.isEmpty( @article.attachments ): %>
<% if !_.isEmpty(@article.attachments): %>
<div class="attachments attachments--list">
<%- @Icon('paperclip') %>
<div class="attachments-title"><%- @article.attachments.length %> <%- @T('Attached Files') %></div>
@ -62,7 +61,6 @@
</div>
</div>
</div>
<div class="article-meta-clip bottom">
<div class="article-content-meta bottom hide">
<div class="article-meta bottom">
@ -71,8 +69,10 @@
<div class="article-meta-value">
<%- @Icon(@article.type.name, 'article-meta-icon') %>
<%- @T(@article.type.name) %>
<% if @article.type.name is 'email': %>
<a class="text-muted" href="<%= App.Config.get('api_path') %>/ticket_article_plain/<%= @article.id %>" target="_blank"><%- @T('raw') %></a>
<% if @article.preferences.links: %>
<% for item in @article.preferences.links: %>
<a class="text-muted" href="<%- item.url %>" target="<%- item.target %>"><%- @T(item.name) %></a>
<% end %>
<% end %>
</div>
</div>

View file

@ -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

View file

@ -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
}

View file

@ -208,7 +208,7 @@ class TweetBase
ticket.save!
end
Ticket::Article.create(
Ticket::Article.create!(
from: from,
to: to,
body: tweet.text,