Fixed issue#317 - Display origin url from tweet/facebook post.
This commit is contained in:
parent
d74444fc30
commit
f8a75f02b8
5 changed files with 47 additions and 10 deletions
|
@ -120,6 +120,17 @@ class ArticleViewItem extends App.ObserverController
|
||||||
article['html'] = App.Utils.text2html(body)
|
article['html'] = App.Utils.text2html(body)
|
||||||
article['html'] = article['html'].replace(signatureDetected, '<span class="js-signatureMarker"></span>')
|
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
|
if article.preferences.delivery_message
|
||||||
@html App.view('ticket_zoom/article_view_delivery_failed')(
|
@html App.view('ticket_zoom/article_view_delivery_failed')(
|
||||||
ticket: @ticket
|
ticket: @ticket
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="article-content">
|
<div class="article-content">
|
||||||
<% if @article.sender.name isnt 'Agent': %>
|
<% if @article.sender.name isnt 'Agent': %>
|
||||||
<% position = 'left' %>
|
<% position = 'left' %>
|
||||||
|
@ -46,7 +45,7 @@
|
||||||
<div class="btn btn--text js-unfold"><%- @T('See more') %></div>
|
<div class="btn btn--text js-unfold"><%- @T('See more') %></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if !_.isEmpty( @article.attachments ): %>
|
<% if !_.isEmpty(@article.attachments): %>
|
||||||
<div class="attachments attachments--list">
|
<div class="attachments attachments--list">
|
||||||
<%- @Icon('paperclip') %>
|
<%- @Icon('paperclip') %>
|
||||||
<div class="attachments-title"><%- @article.attachments.length %> <%- @T('Attached Files') %></div>
|
<div class="attachments-title"><%- @article.attachments.length %> <%- @T('Attached Files') %></div>
|
||||||
|
@ -62,7 +61,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="article-meta-clip bottom">
|
<div class="article-meta-clip bottom">
|
||||||
<div class="article-content-meta bottom hide">
|
<div class="article-content-meta bottom hide">
|
||||||
<div class="article-meta bottom">
|
<div class="article-meta bottom">
|
||||||
|
@ -71,8 +69,10 @@
|
||||||
<div class="article-meta-value">
|
<div class="article-meta-value">
|
||||||
<%- @Icon(@article.type.name, 'article-meta-icon') %>
|
<%- @Icon(@article.type.name, 'article-meta-icon') %>
|
||||||
<%- @T(@article.type.name) %>
|
<%- @T(@article.type.name) %>
|
||||||
<% if @article.type.name is 'email': %>
|
<% if @article.preferences.links: %>
|
||||||
<a class="text-muted" href="<%= App.Config.get('api_path') %>/ticket_article_plain/<%= @article.id %>" target="_blank"><%- @T('raw') %></a>
|
<% for item in @article.preferences.links: %>
|
||||||
|
<a class="text-muted" href="<%- item.url %>" target="<%- item.target %>"><%- @T(item.name) %></a>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Channel::Driver::Facebook
|
||||||
next if page_to_sync_params['group_id'].empty?
|
next if page_to_sync_params['group_id'].empty?
|
||||||
page_client = Facebook.new(page['access_token'])
|
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|
|
posts.each { |post|
|
||||||
|
|
||||||
# ignore older messages
|
# ignore older messages
|
||||||
|
|
|
@ -210,8 +210,7 @@ result
|
||||||
end
|
end
|
||||||
|
|
||||||
state = get_state(page, post)
|
state = get_state(page, post)
|
||||||
|
Ticket.create!(
|
||||||
Ticket.create(
|
|
||||||
customer_id: user.id,
|
customer_id: user.id,
|
||||||
title: title,
|
title: title,
|
||||||
group_id: group_id,
|
group_id: group_id,
|
||||||
|
@ -220,6 +219,9 @@ result
|
||||||
preferences: {
|
preferences: {
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
channel_fb_object_id: page['id'],
|
channel_fb_object_id: page['id'],
|
||||||
|
facebook: {
|
||||||
|
permalink_url: post['permalink_url'],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -260,6 +262,11 @@ result
|
||||||
articles += nested_comments(post['comments']['data'], post['id'])
|
articles += nested_comments(post['comments']['data'], post['id'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
base_url = nil
|
||||||
|
if ticket.preferences['facebook'] && ticket.preferences['facebook']['permalink_url']
|
||||||
|
base_url = ticket.preferences['facebook']['permalink_url']
|
||||||
|
end
|
||||||
|
|
||||||
articles.each { |article|
|
articles.each { |article|
|
||||||
next if Ticket::Article.find_by(message_id: article[:message_id])
|
next if Ticket::Article.find_by(message_id: article[:message_id])
|
||||||
|
|
||||||
|
@ -270,6 +277,22 @@ result
|
||||||
ticket.save!
|
ticket.save!
|
||||||
end
|
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 = {
|
article = {
|
||||||
#to: @account['name'],
|
#to: @account['name'],
|
||||||
ticket_id: ticket.id,
|
ticket_id: ticket.id,
|
||||||
|
@ -277,6 +300,9 @@ result
|
||||||
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
|
preferences: {
|
||||||
|
links: links,
|
||||||
|
},
|
||||||
}.merge(article)
|
}.merge(article)
|
||||||
Ticket::Article.create(article)
|
Ticket::Article.create(article)
|
||||||
}
|
}
|
||||||
|
@ -363,7 +389,7 @@ result
|
||||||
in_reply_to: in_reply_to
|
in_reply_to: in_reply_to
|
||||||
}
|
}
|
||||||
result.push(article_data)
|
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'])
|
sub_articles = nested_comments(sub_comments, comment['id'])
|
||||||
result += sub_articles
|
result += sub_articles
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ class TweetBase
|
||||||
ticket.save!
|
ticket.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
Ticket::Article.create(
|
Ticket::Article.create!(
|
||||||
from: from,
|
from: from,
|
||||||
to: to,
|
to: to,
|
||||||
body: tweet.text,
|
body: tweet.text,
|
||||||
|
|
Loading…
Reference in a new issue