Getting the target user for notification webhook events

I see that webhooks now support notifications which is fantastic. Something we really need. However the payload is missing one critical piece of information - the user the notification is for. In this example payload we can see the author of the post that triggered the notification, but not the user that should receive the notification.

{
  "notification": {
    "id": 119,
    "notification_type": 9,
    "read": false,
    "created_at": "2019-09-18T13:42:21.248Z",
    "post_number": 1,
    "topic_id": 75,
    "fancy_title": "Phallguy should get a notice about this",
    "slug": "phallguy-should-get-a-notice-about-this",
    "data": {
      "topic_title": "Phallguy should get a notice about this",
      "original_post_id": 111,
      "original_post_type": 1,
      "original_username": "Paul_Alexander",
      "revision_number": null,
      "display_username": "Paul_Alexander"
    }
  }
}

I’ve looked to see if there’s an API to get the target user from notification id but haven’t found anything documented. Is there a way we can get the target username/id in the notification payload?

For context, we are trying to consolidate notifications from multiple systems into a single experience for our users.

@Falco or @blake do you have any thoughts on how I can figure out which user a notification is for when received through the new notification webhook?

Just looked at this briefly to see if there was a quick answer, and you are right, it does not look like we have a get api endpoint for fetching an individual notification by id, but that wouldn’t be very efficient to call every time anyways.

Most likely this will require a code change to the notification serializer to include the user_id/username inside of the notification payload, so that a separate api request wouldn’t be necessary.

We’re using the hosted service at the moment otherwise I’d build my own plugin. Would you folks consider adding the user id/username to then notification payload in the webhook?

Did you check the headers?

I did - hoping to find some extra meta data in there but didn’t find anything user specific.

Request URL: https://XXX
Request method: POST
Accept: */*
Connection: close
Content-Length: 420
Content-Type: application/json
Host: XXX
User-Agent: Discourse/2.4.0.beta4
X-Discourse-Instance: https://XXX
X-Discourse-Event-Id: 11
X-Discourse-Event-Type: notification
X-Discourse-Event: notification_created
X-Discourse-Event-Signature: sha256=XXX

여러분의 의견이나 업데이트가 있는지 확인차 연락드립니다. 대상 사용자가 없는 알림 웹훅은 사실 큰 도움이 되지 않습니다.

여러분, 이슈 검토해 보셨나요? 알림 이벤트에서 대상 사용자 ID를 받을 수 있을까요?

알림 웹훅 JSON 페이로드에 user_id를 추가하는 PR을 생성했습니다:

안녕하세요 @blake, 사용자 external_id도 함께 추가할 수 있을까요? 저희는 Discourse의 SSO를 사용하는데, 시스템에 Discourse 사용자 ID가 실제로 존재하지 않습니다.

앨버트님, 안녕하세요!

좋은 아이디어라고 생각합니다. SSO가 활성화된 경우 사용자의 external_id를 추가하는 커밋을 생성해 두었습니다.

도움이 되길 바랍니다! 이번 주 중 배포될 때 사이트에 추가될 것입니다.

와, 엄청 빠르네요! 정말 감사드립니다 :smiley: 호스팅된 Discourse 서버에 이 변경 사항이 적용될 예정된 대략적인 ETA를 알고 계신가요?

아니면 말고, 마지막 문장을 안 읽었네요 :sweat_smile:. 다시 한번 감사해요!!