DEV: Add post_id parameter to reset_bump_date route (#25372)

This would allow a theme component (or an API call) to reset the bump
date of a topic to a given post's created_at date.

I picked `post_id` as the parameter here because it provides a bit of
extra protection against accidentally resetting the bump date to a date
that doesn't make sense.
This commit is contained in:
Penar Musaraj
2024-02-15 00:42:42 -05:00
committed by GitHub
parent 2b30cca0e4
commit c1577019c8
4 changed files with 44 additions and 8 deletions

View File

@ -1151,12 +1151,14 @@ class TopicsController < ApplicationController
def reset_bump_date
params.require(:id)
params.permit(:post_id)
guardian.ensure_can_update_bumped_at!
topic = Topic.find_by(id: params[:id])
raise Discourse::NotFound.new unless topic
topic.reset_bumped_at
topic.reset_bumped_at(params[:post_id])
render body: nil
end