我经常使用 POST /t/:topic_id/timer 操作来更改话题分类(从私密改为公开)。
如果 time 参数设置为未来时间,这可以正常工作;但如果我使用当前时间(或误用了过去的时间),虽然会收到有效的响应,但分类更改不会立即生效。
通常需要 5 到 10 分钟,这可能会让人困惑(我推测这是由于内部轮询循环的频率导致的)。
以下是一个使用过去时间的请求示例及响应:
# 请求
POST /t/4378/timer HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Api-Key: REDACTED
Api-Username: REDACTED
Connection: keep-alive
Content-Length: 96
Content-Type: application/json
Host: REDACTED
User-Agent: HTTPie/2.2.0
{
"category_id": "54",
"status_type": "publish_to_category",
"time": "2020-10-26 08:09:45+01:00"
}
# 响应
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Mon, 26 Oct 2020 07:09:46 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: nginx/1.18.0 (Ubuntu)
Strict-Transport-Security: max-age=63072000;
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Discourse-Route: topics/timer
X-Discourse-Username: REDACTED
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Request-Id: REDACTED
X-Runtime: 0.055819
X-XSS-Protection: 1; mode=block
{
"based_on_last_post": false,
"category_id": 54,
"closed": false,
"duration": null,
"execute_at": "2020-10-26T07:09:45.000Z",
"success": "OK"
}
更新:我原本以为这是 API 独有的问题,但在用户界面(UI)中也可能出现同样的问题。虽然无法选择过去的日期,但可以选择过去的时间。
行为相同:没有任何提示表明已设置计时器,但它仍会在创建后的 5 到 10 分钟内的某个时间触发。
