wiki icon indicating copy to clipboard operation
wiki copied to clipboard

Feature: Email notification on comment

Open gogowitsch opened this issue 2 years ago • 17 comments

This pull requests extends the comment provider named "default" with an email notification. This pull request defines a new job that collects unsent comments. It can notify about multiple comments that were added after the last job ran.

Before merging this we probably need to:

  • [ ] Adjust the name of the server/db/migrations/2.5.292.js file to whatever version this PR lands in.
  • [x] Add a SQLite migration. I have only tested with PostgreSQL.
  • [x] ~~Add some way to trigger the notification job - or explain how to configure it on the server. Right now I use the operating system cron. This works by adding the command node server/core/worker.js --job=send-comment-notification-emails to crontab. I can imagine to find or build a poormanscron feature within the node server, so notifications are triggered by HTTP requests. Then, we'd need to define a frequency, preferably by config.~~
  • [ ] Potentially add a test - please guide me though your expectations here.
  • [ ] Add the new i18text in a proper way. I have tested it by running this SQL:
    update locales
    set strings=jsonb_set(strings, '{emails}', '{
      "notification-email": {
        "subject": "New comments",
        "item": "Comment on page <a href=''{{pagePath}}''>{{pageTitle}}</a> by <a href=''mailto:{{email}}''>{{commentAuthorName}}</a>"
      }
    }', true)
    where code = 'en';
    

I have added a textarea to the comments admin page:
image

gogowitsch avatar Oct 23 '22 13:10 gogowitsch

Here is the link to canny.io: https://feedback.js.wiki/wiki/p/send-an-email-when-a-comment-is-added

image

gogowitsch avatar Oct 23 '22 13:10 gogowitsch

Very cool.

To trigger a job on schedule, you need to add an entry to https://github.com/requarks/wiki/blob/main/server/app/data.yml#L118-L139

NGPixel avatar Oct 24 '22 01:10 NGPixel

Could this be expanded so users can subscribe to certain pages so they only get comment notifications for that page?

mike-lloyd03 avatar Oct 28 '22 22:10 mike-lloyd03

@mike-lloyd03 Sure, but I might not be the person to write the code. Before expanding the feature, I'd like to get this PR merged.

gogowitsch avatar Nov 16 '22 12:11 gogowitsch

@NGPixel I have updated the data.yml and the description of this pull request. Let me know if you need anything else from me to get this mergeable.

gogowitsch avatar Nov 16 '22 15:11 gogowitsch

We have used this feature in our production instance of the wiki for 7 days now and it works great.

@NGPixel Let me know where I can help to get this into a release. Getting English texts into the official i18n seems crucial.

gogowitsch avatar Nov 23 '22 10:11 gogowitsch

Can this be enhanced to send email on the event of the page being changed?

zhuzhzh avatar Mar 13 '23 02:03 zhuzhzh

We have used this feature in our production instance of the wiki for 7 days now and it works great.

@NGPixel Let me know where I can help to get this into a release. Getting English texts into the official i18n seems crucial.

@fonata , just curious, is there any blocking issue for this PR's merge?

farzadpanahi avatar Mar 31 '23 22:03 farzadpanahi

I have a site that will use this as soon as it is merged. We use sqlite and I'd be happy to test or help out.

RandyAbernethy avatar Apr 11 '23 00:04 RandyAbernethy

just curious, is there any blocking issue for this PR's merge?

@farzadpanahi I am not aware of open issues.

gogowitsch avatar Apr 13 '23 10:04 gogowitsch

Can this be enhanced to send email on the event of the page being changed?

@zhuzhzh I suggest that you open another issue or pull request for that, as it is a different feature with different config settings.

gogowitsch avatar Apr 13 '23 10:04 gogowitsch

Hey guys,

To check if we can review that and merge it, it's a feature we are waiting for from a couple of mounts. We can also help with testing it.

vhristev avatar Jun 12 '23 06:06 vhristev

I would absolutely love to see a feature like this land in WikiJS. However, to really be useful, I think we need some more granularity and control similar to what @mike-lloyd03 suggested.

Users should be able to subscribe/unsubscribe to the comments section of any given page. In addition, users should have some level of control over their default subscriptions behavior. For example, if you leave a comment on a page, that could auto-subscribe you if you've enabled it.

What I'm really hoping for, perhaps in WikiJS v3, is a full-blown event driven webhooks abstraction. That could potentially serve as the backbone for comment notifications.

johncmunson avatar Aug 07 '23 20:08 johncmunson