Uitleg over het getimede onderwerpveld op de API

AI-generated summary

A user, mbaker341997, seeks clarification on the timed topic API fields for scheduling topics programmatically. They are confused about the time format, status_type values, and the purpose of based_on_last_post. Arkshine clarifies that status_type includes options like close, open, publish_to_category, delete, reminder, and bump. They also explain that time can be an integer (hours from now), a timestamp (e.g., “2013-11-25 13:00”), or a timestamp with timezone (e.g., “2013-11-26T21:00:00.000Z”), and that based_on_last_post is a boolean indicating whether the time should be relative to the last post’s timestamp. mbaker341997 acknowledges the explanation and references the relevant code in topic.rb for further details.

For my project I would like to programmatically create scheduled topics. I was thinking of using the timed topic api endpoint, but I’m a little confused about some of the fields.

  • id path parameter - straightforward, topic id that’s being scheduled
  • time - what format is this supposed to be in? All it says is “string”.
  • status_type - not sure what its possible values is . i would think it would be similar to the status enum in the update status api but the example on the timer is “publish_to_category”, which isn’t an option in the enum.
  • based_on_last_post - I have no idea what this boolean flag means
  • category_id - straightforward

app/models/topic_timer.rb:

close
open
publish_to_category
delete
reminder
bump
delete_replies

Found some comment in code:

  • An integer, which is the number of hours from now to update the topic’s status.
  • A timestamp, like “2013-11-25 13:00”, when the topic’s status should update.
  • A timestamp with timezone in JSON format. (e.g., “2013-11-26T21:00:00.000Z”)
  • based_on_last_post: True if time should be based on timestamp of the last post.

Thanks reference to the comments: discourse/app/models/topic.rb at 0863c36221130b161d63562a58ac97171475dca5 · discourse/discourse · GitHub

set_or_create_timer method in models/topic.rb contains the logic supporting this API