1# frozen_string_literal: true 2 3module BitbucketServer 4 module Representation 5 class Activity < Representation::Base 6 def comment? 7 action == 'COMMENTED' 8 end 9 10 def inline_comment? 11 !!(comment? && comment_anchor) 12 end 13 14 def comment 15 return unless comment? 16 17 @comment ||= 18 if inline_comment? 19 PullRequestComment.new(raw) 20 else 21 Comment.new(raw) 22 end 23 end 24 25 # TODO Move this into MergeEvent 26 def merge_event? 27 action == 'MERGED' 28 end 29 30 def committer_user 31 commit.dig('committer', 'displayName') 32 end 33 34 def committer_email 35 commit.dig('committer', 'emailAddress') 36 end 37 38 def merge_timestamp 39 timestamp = commit['committerTimestamp'] 40 41 self.class.convert_timestamp(timestamp) 42 end 43 44 def merge_commit 45 commit['id'] 46 end 47 48 def created_at 49 self.class.convert_timestamp(created_date) 50 end 51 52 private 53 54 def commit 55 raw.fetch('commit', {}) 56 end 57 58 def action 59 raw['action'] 60 end 61 62 def comment_anchor 63 raw['commentAnchor'] 64 end 65 66 def created_date 67 raw['createdDate'] 68 end 69 end 70 end 71end 72