lib/ruboty/jira/actions/comment.rb in ruboty-jira-0.2.0 vs lib/ruboty/jira/actions/comment.rb in ruboty-jira-0.3.0
- old
+ new
@@ -1,18 +1,31 @@
module Ruboty
module Jira
module Actions
class Comment < Base
def call
- message.reply(comment)
+ return unless valid_user?
+ comment
rescue => e
message.reply(e.message)
end
private
def comment
- # TODO: main logic
+ issue = find_issue(message[:issue])
+ return message.reply("The issue #{message[:issue]} is not found") if issue.nil?
+ comment = issue.comments.build
+ comment.save!(
+ body: format(message[:comment])
+ )
+ end
+
+ def format(message)
+ <<-"EOF"
+Commented by @#{associate_user[:name]}
+#{message}
+ EOF
end
end
end
end
end