New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email notification upon replies #42

Open
TWiStErRob opened this Issue Nov 12, 2016 · 61 comments

Comments

Projects
None yet
@TWiStErRob

TWiStErRob commented Nov 12, 2016

Usually commenting solutions allow for users to be notified via email about replies to their comments, or in case of a flat commenting stream when anyone posts a new comment. Is it possible to do this with staticman?

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Nov 12, 2016

This is currently in development and will be released soon!

@illus0r

This comment has been minimized.

illus0r commented Nov 22, 2016

@eduardoboucas looking forward to it! I've just discovered, I've received a first comment on my blog. This comment is useful, but I'm not able to say “Thank you” to it's author.

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Nov 23, 2016

The feature is pretty much ready. I could use with some help with testing. Would any of you be interested in being the guinea pig? 😄

@illus0r

This comment has been minimized.

illus0r commented Nov 23, 2016

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Nov 25, 2016

Okay, here's how to get notifications working.

Emails are sent using Mailgun. There is an account associated with the public instance of Staticman, but it comes with a limit of 10,000 emails a month. This limit shouldn't be an issue in the immediate future, but users are encouraged to use their own Mailgun accounts instead. They are free (for the first 10k emails), but you do need a custom domain to use them with. I can possibly provide *.staticman.net subdomains.

To enable notifications, you need a notifications block in your site config and you must be using the config file format introduced in v2 (i.e. having a staticman.yml file, instead of using Jekyll's _config.yml). See the sample config file for more info.

If you're using your own Mailgun account, you'll need to add a Mailgun API key and domain to the config, which need to be encrypted. To encrypt those, you can use the following endpoint: https://api.staticman.net/v2/encrypt/{TEXT TO BE ENCRYPTED}.

Next, your entries will need to specify that a user wishes to subscribe to a specific entry. This is an example:

<form method="POST" action="https://api.staticman.net/v2/entry/joebloggs/my-site/master/comments">
 <input type="hidden" name="options[origin]" value="http://mysite.com/post1.html">
 <input type="hidden" name="options[parent]" value="867bd1e0-921c-11e6-930f-79eeedf443ea">
 
 <input type="text" name="fields[name]" placeholder="Title">
 <input type="text" name="fields[email]" placeholder="Email">
 <textarea name="fields[body]"></textarea>
 <input type="checkbox" name="options[subscribe]" value="email">
 
 <button type="submit">Go!</button>
</form>

In the from above, you can see the following:

  • options[origin] contains the full URL of the entry. This will be included in the email sent to subscribers, allowing them to open the post directly.
  • options[parent] is a unique identifier to the entry the user is subscribing to. This could be the title of a post (although it needs to be URL-friendly, so this needs to be a slug) or the _id field (which is now automatically added to every entry) if you want to subscribe to another comment.
  • options[subscribe] contains the name of the field corresponding to the email address of the subscriber.

Finally, and to make sure we don't send emails asking users to click on links that have been spoofed, you need to add an allowedOrigins field (see docs) to your site config, where you'll specify which domains are valid origins. If you add only mysite.com, then an entry where options[origin] is http://myothersite.com/post1.html will be rejected.

I'm sure there are still a few rough edges, so if any of you can try implementing this and share your feedback that'd be very useful.

Thanks!

@dancwilliams

This comment has been minimized.

dancwilliams commented Nov 25, 2016

Works great! Thanks for your work on this!

@zongren

This comment has been minimized.

Contributor

zongren commented Nov 28, 2016

Is this working on public staticman instance?
I tried it a couple of times and failed.
Here is my staticman.yml:

allowedFields: ["name", "email", "url", "message", "origin", "parent", "subscribe"]
requiredFields: ["name", "message"]
format: "json"
generatedFields:
  date:
    type: "date"
    options:
      format: "iso8601"
moderation: true
branch: "master"
path: _data/{options.slug}
filename: comment-{@timestamp}
transforms:
  email: md5
name: "宗仁的博客"
allowedOrigins: ["localhost", "zongren.me"]
notifications: 
  enabled: true
  apiKey: "qPB1uWby7FS6T0wgLqUfjcQkkVtLkcergXOqiEoZyTo5yqMmGU/cuzOD825KOZkvbE7m0mOYo2LKPj82v+BcQDxxcIULev8lwpQ1KZJwjv6Ei3f1HbFyIq5N2Ehmya3PyPGga3IaedFVTPFrue67DQ2W5+tu8xJX1S2PahUEgAA="
  domain: "FkFQQFNFX96xVIOYvgtB8IxeBP60lZa/sUhHv0Y3KWV3EdRjMLED0zZr6nGGC5opytzczKvQtR2Y6YJvKQ2ltOBV1aFuAvsN/HPnOZ4e5JMBI+BjGWWlaqUsKp/mNGq/q9oWDk3FT8tdfw7UBqa8lC99eYa+QMXj/k+gpPx5ki0="

and comment form:

<form class="comment-form" method="POST" action="https://api.staticman.net/v2/entry/<%- theme.staticman %>">
    <input type="hidden" name="options[origin]" value="<%- config.url %><%- config.root %><%- item.path %>">
    <input type="hidden" name="options[parent]" value="<%- item.slug %>">
    <input type="hidden" name="options[redirect]" value="<%- config.url %><%- config.root %><%- item.path %>">
    <input type="hidden" name="options[slug]" value="<%- item.slug %>">
    <span class="comment-form__input-wrapper">
      <input autocomplete="off" spellcheck="false" class="comment-form__input" name="fields[name]" type="text" placeholder="请输入姓名"/>
    </span>
    <span class="comment-form__input-wrapper">
      <input autocomplete="off" spellcheck="false" class="comment-form__input" name="fields[email]" type="email" placeholder="请输入邮箱(可选)"/>
    </span>
    <span class="comment-form__input-wrapper">
      <input autocomplete="off" spellcheck="false" class="comment-form__input" name="fields[url]" type="url" placeholder="请输入你的网站(可选)"/>
    </span>
    <span class="comment-form__input-wrapper">
    <textarea class="comment-form__input comment-form__input--textarea" name="fields[message]" placeholder="请输入评论内容(支持Markdown)"></textarea>
    </span>
    <input type="checkbox" name="options[subscribe]" value="email" id="subscribe" /><label for="subscribe">订阅此文章的评论</label>
    <button class="comment-form__input comment-form__input--button">提交评论</button>
  </form>

And there are no logs on my mailgun dashboard.

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Nov 28, 2016

@zongren link to the repo, please?

@zongren

This comment has been minimized.

Contributor

zongren commented Nov 28, 2016

@eduardoboucas the repository is at gitlab

@zongren

This comment has been minimized.

Contributor

zongren commented Nov 30, 2016

qq20161130-1 2x

And I used encrypted "zongren.me" as notifications.domain.
@wrbrooks

This comment has been minimized.

Contributor

wrbrooks commented Jan 17, 2017

Hi Eduardo!
Any chance you could check the logs of the staticman service to help me understand why my attempts to get reply notifications aren't working? I think I've configured staticman properly and have a working mailgun account, but I must be doing something wrong.

The repo is wrbrooks.github.io. Thanks in advance!
-W

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Jan 19, 2017

@wrbrooks I don't see any errors in the logs. Can you link to the page you're using to submit entries?

@justinrummel

This comment has been minimized.

justinrummel commented Feb 6, 2017

Hello @eduardoboucas I'm having issues as well w/ Staticman triggering emails with Mailgun. I'm able to validate with Mailgun's example curl statement but cannot trigger anything from my primary test page: https://www.justinrummel.com/macworld-2010-pictures/

(API Key removed)

justinrummel@Rummel-MBPr ~> curl -s --user 'api:key-12341234123412341234123412341234' \
                                https://api.mailgun.net/v3/mg.justinrummel.com/messages \
                                -F from='Excited User <mailgun@mg.justinrummel.com>' \
                                -F to=j@rummel.co \
                                -F subject='Hello' \
                                -F text='Testing some Mailgun awesomness!'
{
  "id": "<20170204203732.129129.51249.1E9B7445@mg.justinrummel.com>",
  "message": "Queued. Thank you."
justinrummel@Rummel-MBPr ~>
@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Feb 6, 2017

@justinrummel Staticman uses the Mailing Lists functionality from Mailgun, where each thread/post is created as a mailing list. If you go to your Mailgun account and navigate to Mailing Lists, do you see any lists created? If so, do you see the email addresses corresponding to the users that have subscribed to that thread?

@justinrummel

This comment has been minimized.

justinrummel commented Feb 12, 2017

I see one mailing list that I think was created from my API tests, but not from the site.

@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 2, 2017

I've been planning how to integrate email notifications onto my blog. I have my comment fields defined somewhat idiosyncratically, so the author's email is authoremail instead of just email. I suppose that probably wouldn't work, since I haven't found where to set the name of the field that Staticman looks for... do you know of a way to make it work, or will I just need to sed all my authoremails into emails?

Also, I saw in your reply to #72 (which brilliantly solved a problem I was having, thanks) that the notifications feature isn't considered fully stable yet. Do you have a sense of how likely it is that an existing staticman notification configuration would continue working as the project continues toward stability?

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Mar 2, 2017

@chuckmasterson You can specify the name of the field that contains the email address. It's the value of options[subscribe]. In your case, that would be:

<input type="hidden" name="options[subscribe]" value="authoremail">

Regarding the stability of the email notification system, I have to admit I've been struggling to find enough time to dedicate to it. In any case, I think the existing configuration format is flexible enough to accommodate any changes in the near future, so I don't foresee any breaking changes.

@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 3, 2017

Completely understand about having time. If I knew the first thing about Node.js I'd try contributing, but alas.

I tried setting up with the advice you gave and got as far as getting some mailing lists created. But nothing triggered sending to these lists. I'll look at it again soon... if you find the time to read this and reply, a couple questions that might help me out are:

  • How does Staticman create the "Alias Address" in Mailgun for each mailing list? Mine looks like a random series of hex digits, but it seems like it should correspond to the _id of some post, or at least something that I see in the YAML of one of the comments.
  • How does Staticman determine what (if any) Alias Address to send notification emails to? I'm not quite wrapping my head around how this is achieved with just the options[parent] field. Does it look at all the files in the post's comment directory and see if any have an _id that matches options[parent]? If so, how does it work if you give it a slug as option[parent], since you aren't telling it whether it's identifying the page or the parent's _id? And how does it make the leap from there to knowing where to send the email?
@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 3, 2017

After writing that, I took a crack at reading the code anyhow, and I think I may have understood enough to make a suggestion that would get us partway to a solution, though not all the way. (I would write this as a pull request but my understanding of Node.js is so weak that I would almost certainly break more than I'd fix.)

Suggestion:

Use a different variable besides options.parent to control subscriptions, perhaps a new one named options.subscribeTo.

Reasoning:

Though I haven't found anywhere you gave explicit directions on how to use options.parent, @mmistakes is already using it in threaded commenting, and a few other people have copied his strategy (I'm one). This strategy relies on options.parent being written into the YAML comment file as _parent. In this strategy _parent (options.parent) is the _id of a child comment's parent.

From what I understand of the Staticman code, Staticman expects options.parent to be some identifier of a post that the user is currently subscribing to. This conflicts with the other usage. If a user is writing a top-level comment on a post, then that comment's _parent will be null, and hence even if the user clicks the "subscribe me" checkbox, no mailing list is created because this condition doesn't get satisfied:

if (subscriptions && options.parent && options.subscribe && this.fields[options.subscribe]) {
  subscriptions.set(options.parent, this.fields[options.subscribe]).catch(err => {
    console.log(err.stack || err)
  })
}

If I follow the logic aright, the only subscriptions that would work with Staticman as it stands are where a user makes a child comment and clicks "subscribe me" - in which case they would get subscribed to all replies to their comment's parent. No one can subscribe to replies to their own comment, only to replies to some top-level comment that already exists.

Although my and mmistakes' use of options.parent here is apparently nonstandard, I think there's reason to favor it over what's currently in the code:

  • It's already employed in several sites.
  • The name parent describes a child comment's parent more intuitively than it describes "what comment the user is currently subscribing to".
  • I don't think you'd be breaking any currently functioning sites. It seems like all the Jekyll pioneers here who have tried implementing Mailgun notifications have gotten stuck at about the same stage I have, and the only one I'm aware of who apparently has it working is mmistakes. (I've left a comment on his site to try to see if notification works in the strange way I've predicted, but it's in moderation right now.) The sites of @justinrummel and @zongren currently have no "subscribe" options and @wrbrooks 's does but I can't test it because no comments are going through at all for me (hey wrbrooks, did you know that?).

I'm not sure what format would make sense for the hypothetical options.subscribeTo as I still don't fully understand how Staticman currently interprets options.parent.

I'm still confused on one point: you mentioned in #76 that options fields aren't written to the comment file, but options.parent sure is getting written. I'm happy with that, but it is also a bit unusual; maybe it would make sense for it to go into the documentation eventually that "options fields generally don't get written to the entry, with the exception of options.parent, which is prefixed with an underscore (_parent) to denote the difference."

I'm happy to be a guinea pig on this feature as I'd definitely like to have it, but I'm also going to be on extended travels with little to no coding starting April 1, so I hope we can all get it figured out by then.

And thanks for Staticman! I hope this helped and wasn't too full of misunderstandings of how the code works.

@mmistakes

This comment has been minimized.

mmistakes commented Mar 3, 2017

@chuckmasterson I just merged in your comment. My understanding is you should get a notification email once a new comment is merged in. I'm going to do that now and make it off the main thread (not a child of your comment to see if your hypothesis is true).

My site takes about 20 minutes to build as it crunches through a bazillion images, so give it that long to see if anything shows up.

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Mar 3, 2017

Thanks for the suggestions, @chuckmasterson. Let me try to answer some of the questions.

How does Staticman create the "Alias Address" in Mailgun for each mailing list? Mine looks like a random series of hex digits, but it seems like it should correspond to the _id of some post, or at least something that I see in the YAML of one of the comments.

Each mailing list has a corresponding email address. This email address is a MD5 hash of the GitHub username, repository and entry id concatenated together. This happens here.

How does Staticman determine what (if any) Alias Address to send notification emails to?

Whenever we process an entry, we take its id, generate the hash described above and check if there's any mailing list with a matching address. If there is, we fire notifications to all the addresses in it. Otherwise, there's nothing to do.

From what I understand of the Staticman code, Staticman expects options.parent to be some identifier of a post that the user is currently subscribing to. This conflicts with the other usage.

My thinking was that options[parent] describes the "thread" that you want to subscribe to. If you're writing a top-level comment as you mentioned, this parent would be an identifier of the post you're commenting on (it could be a title, slug, or anything else that uniquely identifies the entry). If you're commenting on an existing comment, then the parent would be the id of the comment.

Theoretically, it could go on how many levels necessary, but as @mmistakes will be able to tell you, it's probably not a good idea to nest further than 2 levels because otherwise the site generation process becomes too complex.

So the general idea is: options[parent] can be whatever — a post title, slug or a Staticman entry id. All it does is create a mailing list with subscribers for that particular parent, which we use whenever we want to process that entry.

Does this help?

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Mar 3, 2017

And sorry if this has caused confusion and made you have to guess what Staticman does. My intention was to document this whenever I had the chance to make it fully stable, but I understand that people want to use this as soon as it's available, so from now on I'll make sure to document things as they get deployed to the live API.

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Mar 3, 2017

Also:

I'm still confused on one point: you mentioned in #76 that options fields aren't written to the comment file, but options.parent sure is getting written. I'm happy with that, but it is also a bit unusual; maybe it would make sense for it to go into the documentation eventually that "options fields generally don't get written to the entry, with the exception of options.parent, which is prefixed with an underscore (_parent) to denote the difference."

This is very true. This should be in the documentation.

@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 4, 2017

Yeah, it's under this account at chuckmasterson.github.io.

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Mar 6, 2017

@chuckmasterson Do you mind switching your Staticman config to temporarily use the public Mailgun account? All you need to do is disable fromAddress, apiKey and domain from under notifications. This is just so I can more easily test.

@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 9, 2017

Sorry, I was away from computers for a few days.

Just changed the Staticman config over as you requested. If you want to test commenting on a blog post that's up, you can use this post. I don't have a checkbox for subscribing shown right now since I haven't gotten it working, but I'll work on getting a checkbox to show on just that page if that'd be helpful. Otherwise there's also some HTML commented out in the vicinity of the submit button that you could uncomment in DevTools or Firebug.

@mmistakes

This comment has been minimized.

mmistakes commented Mar 10, 2017

@chuckmasterson Looking at this again I completely missed what you were saying about how options[parent] works in regards to a mailing list. I'm thinking it might make sense to stop using it as a child comment identifier and come up with a different field to identify a comment's parent.

Then most of the liquid could stay the same, just with a variable rename and a batch replace of _parent on all the existing comment data files. options[parent] could then be assigned with something like {{ page.url | absolute_url }} in the form which should correctly subscribe a user to the entire comment thread.

Though I do like your suggestion of options.subscribeTo since that describes that field better than options.parent. Guess that one is up to @eduardoboucas if he wants to change the name and potentially break some sites 😉

@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 10, 2017

Yeah, what you described is what I ended up doing - something like sed -i 's/^_parent/replying_to/' */*.yml.

@nakoo

This comment has been minimized.

nakoo commented Mar 19, 2017

I also have same problem. Mailgun only makes mailing list, not sending the email.

@alecsatin

This comment has been minimized.

alecsatin commented Mar 28, 2017

Trying again to get the notifications working correctly with a mailgun account. For the mailgun domain entry in the staticman.yml, mailgun provides this:
API Base URL https://api.mailgun.net/v3/www.somedomain.com
Does this need to be encrypted before adding to staticman.yml?
Encrypting with this command:
https://api.staticman.net/v2/encrypt/https://api.mailgun.net/v3/www.somedomain.com
fails with this message:
Cannot GET /v2/encrypt/https://api.mailgun.net/v3/www.somedomain.com
Probably something simple ... but I'm not seeing it.
Alec

@chuckmasterson

This comment has been minimized.

chuckmasterson commented Mar 30, 2017

@alecsatin Don't use "API Base URL", use the bit that's just labeled "Domain" in the Mailgun interface. In your case I think it'd be just www.alecsatin.com. I tried encrypting that and it worked.

@alecsatin

This comment has been minimized.

alecsatin commented Mar 30, 2017

Thank you. Using https://api.staticman.net/v2/encrypt/www.somedomain.com (with the actual domain) to encrypt works. I've updated the staticman.yml.

I'm still having an issue on the mailgun side. One of the txt entries will not validate no matter what I do at the registrar side. The other txt entry (mx._domainkey.www.somedomain.com) is fine.

@nakoo

This comment has been minimized.

nakoo commented Apr 6, 2017

Is there any settings to use public instance of mailgun, not just adding enabled option? I have failed so many times for using this.

@mattseemon

This comment has been minimized.

mattseemon commented Apr 28, 2017

Hi... trying to get notifications working. Right now, my mailgun account seems to be setup correctly. I followed @mmistakes guide and was able to get everything working fine. At this moment, the only thing not working is the actual notification. While I am testing, I used different email ids to register for the notifications. I can see the mailing list getting updated with the new email id's... however, i am still not receiving the notifications. Is there something I missing. I followed @mmistakes guide to the letter.

@Hund

This comment has been minimized.

Hund commented Jun 12, 2017

Will there be any alternative to Mailgun? Something more anonymous, that doesn't require you to own the domain and doesn't require a phone number?

I have my blog at GitHub pages.

@willymcallister

This comment has been minimized.

Contributor

willymcallister commented Jul 17, 2017

@eduardoboucas: Staticman (public) and my own MailGun account are working great at spinningnumbers.org. Thanks so much for creating a great service.

A feature request: When Staticman sets up a new mailing list at MailGun, is it possible for Staticman to initialize the "Name" field to the post slug? Some sort of clear text indication of what the mailing list is for.

@eduardoboucas

This comment has been minimized.

Owner

eduardoboucas commented Jul 17, 2017

@willymcallister That's great news, thanks! Any chance you could write a little guide describing the process you followed to get it working? I'm sure it would be useful to a lot of people.

As for your feature request, it makes perfect sense. I'll try to look into it soon. If you can, please open a separate issue so it doesn't get lost in this thread.

@binarymist

This comment has been minimized.

Contributor

binarymist commented Dec 31, 2017

Hi @eduardoboucas.

I'm currently unable to receive notification emails.

This is my staticman.yml with the relevant notifications config enabled and the encrypted apiKey and domain.

This is where I post comments from in code.

I'm not receiving any error from the Staticman API and no activity in my mailgun account.

Is my config and POST correct?
Do I need to do something in my mailgun account that I've missed from the docs?

Thanks.

@binarymist

This comment has been minimized.

Contributor

binarymist commented Jan 1, 2018

I think my problem was that I added the mailgun API key without the "key-" prefix. Once I added the correct API key as shown in the mailgun domain information and ran it through https://api.staticman.net/v2/encrypt/ along with my [mailgun-prefix].[my.domain], then submitted a test comment with the options[subscribe] checkbox of the submit form checked, I could then see a mailing list entry turn up in my mailgun account.

At this point notifications were working, but there were still errors in the mailgun Logs tab:

No MX for [mailgun-prefix].[my.domain]

At this point I added the two MX records to my DNS provider that mailgun recommends:
name: mailgun
value: mxa.mailgun.org
name: mailgun
value: mxb.mailgun.org

and tested every scenario I could think of. All working at this stage.

@nakoo

This comment has been minimized.

nakoo commented Jan 2, 2018

@binarymist what do you mean [mailgun-prefix] of the domain?

@binarymist

This comment has been minimized.

Contributor

binarymist commented Jan 2, 2018

what do you mean [mailgun-prefix] of the domain?

The prefix that mailgun recommend their customers use. I think it can be anything, or possibly nothing (by the look of some of the other participants in this thread), but needs to be specified as part of the domain in the RSA'd domain string in the staticman.yml, and in your mailgun account.

@binarymist

This comment has been minimized.

Contributor

binarymist commented Jan 4, 2018

I've just used this functionality for a subscription to any new blog post. Great for capturing your audience and keeping them up to date directly to their inbox gcushen/hugo-academic#427

@wrbrooks

This comment has been minimized.

Contributor

wrbrooks commented Jan 5, 2018

I've found two things, either of which can prevent the sending of reply notifications:

  1. If moderation is on, notifications won't be sent. This is due to lib/Staticman.js, lines 498-507. moderation==true, we go into the code that writes a Pull Request but if moderation==false we go into the logic that checks whether anyone has subscribed to hear about responses to the parent comment.
  2. Both subscriptions and replies are registered to whatever options[parent] was relevant to the comment-leaver, but notifications only fire when these match. This means that only "sibling" comments can notify each other (comments with the same parent.) I think the expected behavior is to see notifications based on replies to your own comment, but the current code will instead notify when someone replies to the same comment you replied to.

I think the way to address (2) is to change the part of lib/Staticman.js line 490 that is like:

 subscriptions.set(options.parent, this.fields[options.subscribe])

to be something like

 subscriptions.set(options._id, this.fields[options.subscribe])

instead (I don't know when the _id variable is assigned, though.) Then, the commenter can be notified when people reply to them.

Edited to add:

I think another common source of confusion comes from the fact that comments with parent set to nil cannot subscribe to reply notifications. This is because parent is part of the string that gets hashed to create a unique comment notification thread. The options[parent] property is set in HTML (usually by a Jekyll variable) but some of the projects linked in the README don't populate options[parent] for top-level comments. When I caught that, I started populating top-level parents with the {{ post.slug }} but I still had to be careful because the for loops that copy out the comments seem to want options[parent] to resolve to an integer. As far as I can tell, there is no reason that has to be, but you'll often see code like:

{% assign p       = comment._parent %}
{% assign parent  = p | to_integer %}

in the for loop. So far I have been able to replace that second line by

{% assign parent  = p %}

with no ill effect.

@nakoo

This comment has been minimized.

nakoo commented Jan 5, 2018

@wrbrooks Thanks. I finally can get the notification mail. What I only changed is moderation: true to false. Mailgun Logs show me the success messages. But still, I find the way using notification without moderation to false.

@wrbrooks

This comment has been minimized.

Contributor

wrbrooks commented Jan 5, 2018

After some further investigation, I figured out how to get notifications to send when moderation is enabled: you have to add a webhook to your repository, pointed at

https://api.staticman.net/v1/webhook

Note that this is true even if you're using the v2 API for comments.

This fix is kind of obvious in retrospect (notifications only go out when the comment is accepted, but how was staticman going to know that the comment had been accepted?), but the documentation only mentions the webhook API in reference to automagically deleting the staticman_ branches after they are merged.

I think there should be a clarification in the documentation section about reply notifications to say that when moderation is enabled, sending notifications requires that you add the staticman webhook to your website's repository.

@nakoo

This comment has been minimized.

nakoo commented Jan 5, 2018

@wrbrooks Perfect. I finally made it. Thanks for goodness.

@binarymist

This comment has been minimized.

Contributor

binarymist commented Mar 13, 2018

The main problem I'm (and my commenters) seeing is the multiple Staticman notifications for every comment: #182

MunifTanjim added a commit to MunifTanjim/minimo that referenced this issue Apr 25, 2018

fix [templates]: staticman comments (incorrect field implementation)
change `options[parent]` to `fields[parent_id]`
`options[parent]` is used to identify subscription entries (eduardoboucas/staticman#42 (comment))
@chmac

This comment has been minimized.

Collaborator

chmac commented Jun 15, 2018

@eduardoboucas Haven't read this issue in detail yet, but I could put some time into this if you like. I've just started thinking that I really want reply notifications and saw this and #35. Will wait for the go ahead, and if you're happy, put some effort into this. I'm offline next week, and only online a few days the following week, so might be 3-6 weeks before I get to it...

@chmac chmac self-assigned this Jun 15, 2018

@samarulmeu

This comment has been minimized.

samarulmeu commented Oct 22, 2018

I finally managed to get notification working with mailgun (in fact only adding the emails to a mailing list). Most of the trouble and stress was because I was trying to use a domain in the EU region. There is a difference in the API base URL: https://api.eu.mailgun.net/v3/ vs https://api.mailgun.net/v3/.
Is there a way to specify the EU region?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment