houston/houston-core

View on GitHub
templates/new-instance/config/conversations/mentions/unfurl_tasks.rb

Summary

Maintainability
A
0 mins
Test Coverage
Houston::Slack.config do
  overhear(/\b(?<task>\d+[a-z]+)\b/) do |e|
    next unless e.user
    tasks = Task.joins(:ticket)

    if project = e.channel.name != "test" && Project.find_by_slug(e.channel.name)
      tasks = tasks.where(Ticket.arel_table[:project_id].eq(project.id))
    else
      tasks = tasks.merge(Ticket.open)
    end

    tasks.with_shorthand(e.match[:task]).each do |task|
      e.unfurl slack_task_attachment(task)
    end
  end
end