Topic Event webhook 故障 - 虚假的 topic_created 消息

我想在新主题出现时采取一些行动。因此,我为主题事件启用了 webhook。我检查标头以查看它是否是 topic_created 事件,如果是,我将采取行动。

这已经运行了好几个月,但现在有时会失败,可能是在上周升级之后。现在有时我会在标头中收到 topic_created,但该主题实际上是旧的,只是有人回复了该主题。

我的代码:

    event_type = request.headers['X-Discourse-Event-Type']
    event = request.headers['X-Discourse-Event']
    if event_type == 'topic' and event == 'topic_created':
         take_action()

来自一个标头中包含 event == ‘topic_created’ 的请求的示例 payload。请注意,所谓的“新”主题实际上创建于 2017 年,已有 306 条回复。

payload
{
	'bookmarked': False,
	'word_count': 272108,
	'visible': True,
	'like_count': 567,
	'highest_post_number': 758,
	'has_deleted': True,
	'tags_descriptions': {},
	'deleted_at': None,
	'archetype': 'regular',
	'id': 1357,
	'pinned_until': None,
	'archived': False,
	'user_id': 4,
	'title': 'Tax Time! Discussions of Taxes and Accountants',
	'last_posted_at': '2022-01-05T01:41:26.000Z',
	'tags': [],
	'created_by': {
		'username': 'redacted',
		'avatar_template': '/user_avatar/forum.redacted.com/redacted/{size}/45_2.png',
		'id': 4,
		'name': 'redacted'
	},
	'pinned': False,
	'queued_posts_count': 0,
	'closed': False,
	'unpinned': None,
	'participant_count': 162,
	'views': 19557,
	'pinned_at': None,
	'last_poster': {
		'username': 'redacted',
		'avatar_template': '/letter_avatar_proxy/v4/letter/j/45deac/{size}.png',
		'id': 142,
		'name': 'JohnJacobs'
	},
	'pending_posts': [],
	'posts_count': 744,
	'slug': 'tax-time-discussions-of-taxes-and-accountants',
	'thumbnails': None,
	'created_at': '2017-01-21T00:25:01.000Z',
	'deleted_by': None,
	'featured_link': None,
	'reply_count': 306,
	'pinned_globally': False,
	'category_id': 16,
	'fancy_title': 'Tax Time! Discussions of Taxes and Accountants'
}
2 个赞

有证据表明,当有人通过电子邮件回复时,会触发虚假的 topic_created 消息。

我在这里添加了一个修复程序

1 个赞

此主题已在 18 小时后自动关闭。不再允许回复。