Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions app/models/certification/ship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,40 @@ def post_decision_to_timeline!
def notify_owner!
return unless owner&.slack_id.present?

routes = Rails.application.routes.url_helpers
url_opts = Rails.application.config.action_controller.default_url_options
.reverse_merge(host: "stardance.hackclub.com", protocol: "https")

locals = {
project_title: project.title,
project_url: routes.project_url(project, **url_opts),
feedback: feedback.to_s,
video_url: verdict_video.attached? ? routes.rails_blob_url(verdict_video, **url_opts) : nil
}

case status.to_sym
when :approved
owner.dm_user("Your project '#{project.title}' was approved. It's out for voting now.")
msg = "Your project '#{project.title}' was approved. It's out for voting now."
msg += "\n\nFeedback: #{feedback}" if feedback.present?

SendSlackDmJob.perform_later(
owner.slack_id,
msg,
blocks_path: "notifications/projects/approved",
locals: locals,
sent_by_id: reviewer_id
)
when :returned
msg = "Your project '#{project.title}' needs changes before it can ship."
msg += "\n\n#{feedback}" if feedback.present?
owner.dm_user(msg)
msg += "\n\nFeedback: #{feedback}" if feedback.present?

SendSlackDmJob.perform_later(
owner.slack_id,
msg,
blocks_path: "notifications/projects/returned",
locals: locals,
sent_by_id: reviewer_id
)
end
end
end
Expand Down
22 changes: 22 additions & 0 deletions app/views/notifications/projects/approved.slack_message.slocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
header ":sparkles: Your project was approved!"

section "Your project *<#{project_url}|#{project_title}>* has been approved and is now out for voting.", markdown: true

if feedback.present?
section "*Feedback:* #{feedback}", markdown: true
end

if video_url.present?
section "*Walkthrough Video:* <#{video_url}|Click here to watch>", markdown: true
end

if video_url.present?
actions [
button("View project", "view_project", url: project_url),
button("Watch review video", "watch_video", url: video_url)
]
else
actions [
button("View project", "view_project", url: project_url)
]
end
22 changes: 22 additions & 0 deletions app/views/notifications/projects/returned.slack_message.slocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
header ":x: Changes requested for your project"

section "Your project *<#{project_url}|#{project_title}>* needs changes before it can ship.", markdown: true

if feedback.present?
section "*Feedback:* #{feedback}", markdown: true
end

if video_url.present?
section "*Walkthrough Video:* <#{video_url}|Click here to watch>", markdown: true
end

if video_url.present?
actions [
button("View project", "view_project", url: project_url),
button("Watch review video", "watch_video", url: video_url)
]
else
actions [
button("View project", "view_project", url: project_url)
]
end