Added tweet and dm reply feature.
This commit is contained in:
parent
5492c3889e
commit
b93b4b5579
2 changed files with 40 additions and 9 deletions
|
@ -103,6 +103,13 @@ class App.TicketZoomArticleActions extends App.Controller
|
||||||
icon: 'reply'
|
icon: 'reply'
|
||||||
href: '#'
|
href: '#'
|
||||||
}
|
}
|
||||||
|
if article.type.name is 'twitter direct-message'
|
||||||
|
actions.push {
|
||||||
|
name: 'reply'
|
||||||
|
type: 'twitterDirectMessageReply'
|
||||||
|
icon: 'reply'
|
||||||
|
href: '#'
|
||||||
|
}
|
||||||
|
|
||||||
actions.push {
|
actions.push {
|
||||||
name: 'split'
|
name: 'split'
|
||||||
|
@ -118,6 +125,7 @@ class App.TicketZoomArticleActions extends App.Controller
|
||||||
# get reference article
|
# get reference article
|
||||||
article_id = $(e.target).parents('[data-id]').data('id')
|
article_id = $(e.target).parents('[data-id]').data('id')
|
||||||
article = App.TicketArticle.fullLocal(article_id)
|
article = App.TicketArticle.fullLocal(article_id)
|
||||||
|
sender = App.TicketArticleSender.find(article.sender_id)
|
||||||
type = App.TicketArticleType.find(article.type_id)
|
type = App.TicketArticleType.find(article.type_id)
|
||||||
customer = App.User.find(article.created_by_id)
|
customer = App.User.find(article.created_by_id)
|
||||||
|
|
||||||
|
@ -135,18 +143,33 @@ class App.TicketZoomArticleActions extends App.Controller
|
||||||
articleNew.in_reply_to = article.message_id
|
articleNew.in_reply_to = article.message_id
|
||||||
|
|
||||||
# get current body
|
# get current body
|
||||||
body = @el.closest('.ticketZoom').find('.article-add [data-name="body"]').html() || ''
|
body = @el.closest('.ticketZoom').find('.article-add [data-name="body"]').html().trim() || ''
|
||||||
articleNew.body = body
|
articleNew.body = body
|
||||||
|
|
||||||
to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
recipients = article.from
|
||||||
recipient = "@#{to} "
|
if article.to
|
||||||
|
if recipients
|
||||||
|
recipients += ' '
|
||||||
|
recipients += article.to
|
||||||
|
|
||||||
if !body
|
if recipients
|
||||||
articleNew.body = recipient
|
recipientString = ''
|
||||||
|
recipientScreenNames = recipients.split(' ')
|
||||||
|
for recipientScreenName in recipientScreenNames
|
||||||
|
|
||||||
if body && !body.match("@#{to}")
|
# exclude already listed screen name
|
||||||
articleNew.body = "#{recipient}#{articleNew.body}"
|
if !body || !body.match(recipientScreenName)
|
||||||
|
|
||||||
|
# exclude own screen_name
|
||||||
|
if !body || !body.match(@ticket.preferences.channel_screen_name)
|
||||||
|
if recipientString isnt ''
|
||||||
|
recipientString += ' '
|
||||||
|
recipientString += recipientScreenName.trim()
|
||||||
|
|
||||||
|
if body
|
||||||
|
articleNew.body = "#{recipientString} #{body} "
|
||||||
|
else
|
||||||
|
articleNew.body = "#{recipientString} "
|
||||||
|
|
||||||
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } )
|
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } )
|
||||||
|
|
||||||
|
@ -157,6 +180,7 @@ class App.TicketZoomArticleActions extends App.Controller
|
||||||
article_id = $(e.target).parents('[data-id]').data('id')
|
article_id = $(e.target).parents('[data-id]').data('id')
|
||||||
article = App.TicketArticle.fullLocal(article_id)
|
article = App.TicketArticle.fullLocal(article_id)
|
||||||
type = App.TicketArticleType.find(article.type_id)
|
type = App.TicketArticleType.find(article.type_id)
|
||||||
|
sender = App.TicketArticleSender.find(article.sender_id)
|
||||||
customer = App.User.find(article.created_by_id)
|
customer = App.User.find(article.created_by_id)
|
||||||
|
|
||||||
@scrollToCompose()
|
@scrollToCompose()
|
||||||
|
@ -172,7 +196,13 @@ class App.TicketZoomArticleActions extends App.Controller
|
||||||
if article.message_id
|
if article.message_id
|
||||||
articleNew.in_reply_to = article.message_id
|
articleNew.in_reply_to = article.message_id
|
||||||
|
|
||||||
articleNew.to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
if sender.name is 'Agent'
|
||||||
|
articleNew.to = article.to
|
||||||
|
else
|
||||||
|
articleNew.to = article.from
|
||||||
|
|
||||||
|
if !articleNew.to
|
||||||
|
articleNew.to = customer.accounts['twitter'].username || customer.accounts['twitter'].uid
|
||||||
|
|
||||||
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } )
|
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } )
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ class TweetBase
|
||||||
state: Ticket::State.find_by(name: 'new'),
|
state: Ticket::State.find_by(name: 'new'),
|
||||||
priority: Ticket::Priority.find_by(name: '2 normal'),
|
priority: Ticket::Priority.find_by(name: '2 normal'),
|
||||||
preferences: {
|
preferences: {
|
||||||
channel_id: channel.id
|
channel_id: channel.id,
|
||||||
|
channel_screen_name: channel.options['user']['screen_name'],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue