2018-06-27 17:25:09 -04:00
|
|
|
module BitbucketServer
|
|
|
|
module Representation
|
|
|
|
class Activity < Representation::Base
|
|
|
|
def action
|
|
|
|
raw['action']
|
|
|
|
end
|
|
|
|
|
|
|
|
def comment?
|
|
|
|
action == 'COMMENTED'.freeze
|
|
|
|
end
|
|
|
|
|
|
|
|
def inline_comment?
|
2018-06-28 03:50:10 -04:00
|
|
|
comment? && comment_anchor
|
2018-06-27 17:25:09 -04:00
|
|
|
end
|
|
|
|
|
2018-06-28 03:27:04 -04:00
|
|
|
def comment
|
|
|
|
return unless comment?
|
2018-06-27 17:25:09 -04:00
|
|
|
|
2018-06-28 03:27:04 -04:00
|
|
|
@comment ||=
|
|
|
|
if inline_comment?
|
2018-06-28 03:50:10 -04:00
|
|
|
PullRequestComment.new(raw)
|
2018-06-28 03:27:04 -04:00
|
|
|
else
|
2018-06-28 03:50:10 -04:00
|
|
|
Comment.new(raw)
|
2018-06-28 03:27:04 -04:00
|
|
|
end
|
2018-06-27 17:25:09 -04:00
|
|
|
end
|
|
|
|
|
2018-06-28 03:27:04 -04:00
|
|
|
# XXX Move this into MergeEvent
|
2018-06-27 17:25:09 -04:00
|
|
|
def merge_event?
|
|
|
|
action == 'MERGED'
|
|
|
|
end
|
|
|
|
|
2018-06-28 03:27:04 -04:00
|
|
|
def committer_user
|
2018-06-27 17:25:09 -04:00
|
|
|
commit.fetch('committer', {})['displayName']
|
|
|
|
end
|
|
|
|
|
2018-06-28 03:27:04 -04:00
|
|
|
def committer_email
|
2018-06-27 17:25:09 -04:00
|
|
|
commit.fetch('committer', {})['emailAddress']
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_timestamp
|
|
|
|
timestamp = commit.fetch('committer', {})['commiterTimestamp']
|
|
|
|
|
|
|
|
Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer)
|
|
|
|
end
|
|
|
|
|
|
|
|
def commit
|
|
|
|
raw.fetch('commit', {})
|
|
|
|
end
|
|
|
|
|
|
|
|
def created_at
|
|
|
|
Time.at(created_date / 1000) if created_date.is_a?(Integer)
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
|
|
|
Time.at(updated_date / 1000) if created_date.is_a?(Integer)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-06-28 03:27:04 -04:00
|
|
|
def raw_comment
|
2018-06-27 17:25:09 -04:00
|
|
|
raw.fetch('comment', {})
|
|
|
|
end
|
|
|
|
|
2018-06-28 03:50:10 -04:00
|
|
|
def comment_anchor
|
|
|
|
raw['commentAnchor']
|
|
|
|
end
|
|
|
|
|
2018-06-27 17:25:09 -04:00
|
|
|
def author
|
2018-06-28 03:27:04 -04:00
|
|
|
raw_comment.fetch('author', {})
|
2018-06-27 17:25:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def created_date
|
|
|
|
comment['createdDate']
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_date
|
|
|
|
comment['updatedDate']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|