How to detect draft topic via webhooks?

Hi, I have custom Discourse webhook integration for notifications about new topics in chat server and I started to use draft feature for staff.

Unfortunately I don’t see any variable that I can check for to prevent exposing staff-stuff to regular users.

Am I missing something?

Request URL: <redacted>
Request method: POST
Accept: */*
Connection: close
Content-Length: 1063
Content-Type: application/json
Host: <redacted>
User-Agent: Discourse/2.2.0.beta4
X-Discourse-Instance: <redacted>
X-Discourse-Event-Id: 9605
X-Discourse-Event-Type: topic
X-Discourse-Event: topic_created
X-Discourse-Event-Signature: sha256=<redacted>
{
  "topic": {
    "tags": [],
    "id": 9091,
    "title": "<redacted>",
    "fancy_title": "<redacted>",
    "posts_count": 1,
    "created_at": "2018-11-26T18:01:33.367Z",
    "views": 0,
    "reply_count": 0,
    "like_count": 0,
    "last_posted_at": "2018-11-26T18:01:33.521Z",
    "visible": true,
    "closed": false,
    "archived": false,
    "archetype": "regular",
    "slug": "<redacted>",
    "category_id": 4,
    "word_count": 4,
    "deleted_at": null,
    "pending_posts_count": 0,
    "user_id": 1,
    "featured_link": null,
    "pinned_globally": false,
    "pinned_at": null,
    "pinned_until": null,
    "unpinned": null,
    "pinned": false,
    "highest_post_number": 1,
    "deleted_by": null,
    "has_deleted": false,
    "bookmarked": null,
    "participant_count": 1,
    "created_by": {
      "id": 1,
      "username": "<redacted>",
      "name": "<redacted>",
      "avatar_template": "<redacted>"
    },
    "last_poster": {
      "id": 1,
      "username": "<redacted>",
      "name": "<redacted>",
      "avatar_template": "<redacted>"
    }
  }
}

When a shared draft is created, the category_id will be set to the ID of the shared drafts category. You could try checking the category_id and then not publishing the topic if it comes from your shared drafts category.

3 Likes