Class: Marlens::GithubToJiraComment::CommentPoster

Inherits:
Object
  • Object
show all
Defined in:
lib/marlens/github_to_jira_comment/comment_poster.rb

Constant Summary collapse

DEFAULT_IMAGE_HOSTS =
["github.com", "private-user-images.githubusercontent.com", "user-images.githubusercontent.com"].freeze

Instance Method Summary collapse

Constructor Details

#initialize(jira_client:) ⇒ CommentPoster

Returns a new instance of CommentPoster.



8
9
10
# File 'lib/marlens/github_to_jira_comment/comment_poster.rb', line 8

def initialize(jira_client:)
  @jira_client = jira_client
end

Instance Method Details

#create(issue_key:, markdown:, allowed_image_hosts: []) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/marlens/github_to_jira_comment/comment_poster.rb', line 20

def create(issue_key:, markdown:, allowed_image_hosts: [])
  hosts = (DEFAULT_IMAGE_HOSTS + allowed_image_hosts).uniq
  @jira_client.create_markdown_comment(
    issue_key:,
    markdown:,
    allowed_image_hosts: hosts,
    strict_images: true,
    image_upload_failures: []
  )
end

#post(jira_url:, markdown:, allowed_image_hosts: DEFAULT_IMAGE_HOSTS) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/marlens/github_to_jira_comment/comment_poster.rb', line 12

def post(jira_url:, markdown:, allowed_image_hosts: DEFAULT_IMAGE_HOSTS)
  create(
    issue_key: JiraUrl.parse(jira_url).issue_key,
    markdown:,
    allowed_image_hosts:
  )
end