jafeth.diazc is having trouble providing a custom URL for a custom notification type in Discourse. The current notification-item widget does not support custom URLs for custom notification types.
jafeth.diazc proposes adding a conditional statement to the url method to return a custom URL if the notification type is custom. However, jafeth.diazc is unsure if this is the best approach, as custom notifications are not commonly used in plugins.
sam suggests moving away from custom notifications altogether and instead sending a PR to reserve a notification number for core. According to sam, the custom notification system has become “super messy.”
I know that if I create a custom type notification, I can provide a data.message field with a I18n scope value to form the text of the notification. This is the code in the notification-item widget:
I expected to hear from an experienced developer whether creating custom notifications is something “advisable”. I say this since I haven’t seen plugins doing it (if someone has, please let me know) nor many topics related (others than this one, which I’ve followed to create a custom notification from the backend).
In any case, I was thinking in submitting a PR to add something like the following snippet at the bottom of the url method. That would solve my problem and even be useful for other plugin developers.
if (attrs.notification_type === CUSTOM_TYPE) {
return data.custom_url;
}
Even if it’s not worth its merging, I think I could reopen the widget and do the same, but I would need the widget to be exported, so another PR