move icon_url to author

This commit is contained in:
suer
2014-03-02 20:16:25 +09:00
parent 5c2984d1a6
commit dd0ed3a0d6
3 changed files with 18 additions and 9 deletions

View File

@@ -26,6 +26,7 @@ Post Data Example
"payload": {
"issue": {
"author": {
"icon_url": "http://www.gravatar.com/avatar/example",
"identity_url": null,
"lastname": "user",
"firstname": "test",
@@ -69,8 +70,7 @@ Post Data Example
}
},
"action": "opened",
"url": "https://example.com",
"icon_url": "http://www.gravatar.com/avatar/example"
"url": "https://example.com"
}
}
@@ -78,11 +78,11 @@ Post Data Example
{
"payload": {
"icon_url": "http://www.gravatar.com/avatar/example",
"url": "https://example.com",
"journal": {
"details": [],
"author": {
"icon_url": "http://www.gravatar.com/avatar/example",
"identity_url": null,
"lastname": "user",
"firstname": "test",
@@ -97,6 +97,7 @@ Post Data Example
},
"issue": {
"author": {
"icon_url": "http://www.gravatar.com/avatar/example",
"identity_url": null,
"lastname": "user",
"firstname": "test",

View File

@@ -1,4 +1,7 @@
class RedmineWebhook::AuthorWrapper
include GravatarHelper::PublicMethods
include ERB::Util
def initialize(author)
@author = author
end
@@ -11,6 +14,15 @@ class RedmineWebhook::AuthorWrapper
:firstname => @author.firstname,
:lastname => @author.lastname,
:identity_url => @author.identity_url,
:icon_url => icon_url
}
end
def icon_url
if @author.mail.blank?
icon_url = nil
else
icon_url = gravatar_url(@author.mail)
end
end
end

View File

@@ -1,6 +1,4 @@
class RedmineWebhook::WebhookListener < Redmine::Hook::Listener
include GravatarHelper::PublicMethods
include ERB::Util
def controller_issues_new_after_save(context = {})
issue = context[:issue]
@@ -27,8 +25,7 @@ class RedmineWebhook::WebhookListener < Redmine::Hook::Listener
:payload => {
:action => 'opened',
:issue => RedmineWebhook::IssueWrapper.new(issue).to_hash,
:url => controller.issue_url(issue),
:icon_url => gravatar_url(issue.author.mail)
:url => controller.issue_url(issue)
}
}.to_json
end
@@ -39,8 +36,7 @@ class RedmineWebhook::WebhookListener < Redmine::Hook::Listener
:action => 'updated',
:issue => RedmineWebhook::IssueWrapper.new(issue).to_hash,
:journal => RedmineWebhook::JournalWrapper.new(journal).to_hash,
:url => controller.issue_url(issue),
:icon_url => gravatar_url(issue.author.mail)
:url => controller.issue_url(issue)
}
}.to_json
end