FEATURE: Add skip notification option to group invite to topic (#29741)

* FEATURE: Add skip notification option to group invite to topic

* DEV: rename `skip_notification` to `should_notify`

* DEV: update `should_notify` param to be default `true` in controllers

* DEV: update spec to use `greater than` instead of `equal to` to prevent flakiness

* Update app/controllers/topics_controller.rb

Co-authored-by: David Taylor <david@taylorhq.com>

* DEV: merged two `#invite_group` specs into one

* DEV: Added test case for `invite-group` in requests spec

---------

Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
Gabriel Grubba
2024-11-14 13:00:15 -03:00
committed by GitHub
parent 9b691853e0
commit b39c30045b
5 changed files with 120 additions and 28 deletions

View File

@ -757,7 +757,13 @@ class TopicsController < ApplicationController
if topic.private_message?
guardian.ensure_can_invite_group_to_private_message!(group, topic)
topic.invite_group(current_user, group)
should_notify =
if params[:should_notify].blank?
true
else
params[:should_notify].to_s == "true"
end
topic.invite_group(current_user, group, should_notify: should_notify)
render_json_dump BasicGroupSerializer.new(group, scope: guardian, root: "group")
else
render json: failed_json, status: 422