1
Vote

Comment Workflow Tough to Work With - Fix Included

description

The comments are tough to wrap a workflow around. When a comment is added it is:
  • Created twice (so the workflow is fired twice if you use Content Created event)
  • Published twice (so the workflow is fired twice if you use Content Published event)
  • Update only occurs once (but that seems backward to use Content Updated for the event)
Assuming using Content Updated works, there are no events fired for comment approved, deleted, or moderated (would be nice to trigger a workflow off them).

Finally, if CommentPart.RepliedOn field were tokenized then (possibly) could use tokens to grab the previous content item (comment) being replied to to notify that person some has commented on their comment (possibilities get really fun then).

And, if we exposed the CommentPart.Status field we could check the value in our workflow and decide whether to notify the RepliedTo person (or wait until the status is approved then notify them).

This isn't a complaint though, just a wishlist. I think I can address some of these and will post the results back here. The goal is to take comments from Good to Great - pun intended.

file attachments

comments

jao28 wrote Sep 20, 2013 at 9:13 PM

Correction, it is only "Approve" and "Unapprove" (and the nonce method of the same name) that don't trigger off the Update event. If you go to the Comments section of the dashboard and press "Edit" then "Approve" or "Unapprove" it will fire off the update event.

I have completed the token section "wished" for above and should be able to finish up the Update event on "Approve" and "Unapprove" shortly. Once done, I will post my code here for usage by others and hopefully to make it into core.

jao28 wrote Sep 21, 2013 at 1:39 AM

I have all of the above working, and am working on updating the CreateProtectedUrl to be able to work outside of HttpContext so that the workflows can be utilized on a timer delay - explained in a question here: https://orchard.codeplex.com/discussions/458626. I will post all I have in a day or so if I don't find a better way to resolve HttpContext.

jao28 wrote Sep 21, 2013 at 9:21 PM

Thanks to Piedone, I have been able to resolve the HttpContext and have comments sent on a timer delay. There were two files changed in this process (and I have attached them):
  • Orchard.Comments.Services.CommentService.cs
  • Orchard.Comments.Tokens.CommentTokens.cs
To see the differences, you can compare the versions use source control or just search for the "ADDED BY EMS" comments (which can be removed of course).