HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Would it be possible to send a notification when an answer has been Accepted or Rejected?

edited August 2012 in Feedback

As per subject, my client would like Users to receive a notification when their answers are accepted or rejected. I had a look at the plugin, and I see that it calls AddActivity when an answer is accepted. Would it be possible to do the same when an answer is rejected?

Also, would it be possible to make these notifications optional, the same way it's done with others (e.g Notify me when people write on my wall) ?

«1

Comments

  • Update: after making some experiments, I think I achieved what I wanted. It was simpler than I thought, just a handful of lines of code.

    May I submit the changes for review, and eventually have them added to the main plugin? They don't interfere with main logic, and I believe other people could use them. Thanks.

  • mcu_hqmcu_hq ✭✭✭
    edited August 2012

    I don't see why not...try issuing a pull request here and see if they accept it.

    https://github.com/vanillaforums/Addons/tree/master/plugins/QnA

  • @mcu_hq Thanks, I was looking for that! Time to refresh mi Git skills.

  • ToddTodd Vanilla Staff

    We do love accepting pull requests. Sending an email upon answer rejection is something that would need a config option since most people aren't supposed to know their answer has been rejected.

  • @Todd Thanks, I'm issuing a Pull Request right now. I haven't thought about a global configuration setting for notifications, therefore my update only allows Users to choose if they want to receive the notification.

  • How can I remove all notifications related to this plugin (i.e. when an answer is accepted - don't send any email). I've looked through the https://github.com/vanillaforums/Addons/tree/master/plugins/QnA but couldn't find anything related to this.

    Also, would it be possible to make these notifications optional, the same way it's done with others (e.g Notify me when people write on my wall) ?

    My screenshot below doesn't list these as available options, not sure if I'm just doing something wrong. I'm hoping this could be as easy as just writing a $Configuration string.

    Q& A prefs

  • How can I remove all notifications related to this plugin (i.e. when an answer is accepted - don't send any email). I've looked through the https://github.com/vanillaforums/Addons/tree/master/plugins/QnA but couldn't find anything related to this.

    you would have to change the plugin

    comment out

    $Sender->InformMessage

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thank You! I just didn't know where to look.

  • Unfortunately the two related code strings I can find with what you've mentioned are:

    static $InformMessage = TRUE; if ($InformMessage && Gdn::Session()->UserID == GetValue('InsertUserID', $Discussion) && in_array(GetValue('QnA', $Discussion), array('', 'Answered'))) { $Sender->InformMessage(T('Click accept or reject beside an answer.'), 'Dismissable'); $InformMessage = FALSE;

    and

    $Count = Gdn::SQL()->GetCount('Discussion', array('Type' => 'Question', 'InsertUserID' => Gdn::Session()->UserID, 'QnA' => 'Answered')); if ($Count > 0) { $Sender->InformMessage(FormatString(T("You've asked questions that have now been answered", "<a href=\"{/discussions/mine?qna=Answered,url}\">You've asked questions that now have answers</a>. Make sure you accept/reject the answers.")), 'Dismissable'); } }

    When altering these (i.e. changing from TRUE to FALSE, this only disables the popups that this command prompts. I'll keep looking around the plugin to see where to disable this email notification.

  • peregrineperegrine MVP
    edited March 2013

    I thought thats what you wanted notification messages. You probably have to block email when it gets written to activity. I'll see if I can find it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • kirkpa31kirkpa31 ✭✭
    edited March 2013

    well changing

    // Record the activity. if ($QnA == 'Accepted') { AddActivity( Gdn::Session()->UserID, 'AnswerAccepted', Anchor(Gdn_Format::Text($Discussion['Name']), "/discussion/{$Discussion['DiscussionID']}/".Gdn_Format::Url($Discussion['Name'])), $Comment['InsertUserID'], "/discussion/comment/{$Comment['CommentID']}/#Comment_{$Comment['CommentID']}", TRUE ); } }

    from TRUE to FALSE disables email notifications while not disabling the popups on the page, but it also disables non-email notifications within the forum itself. No activity is recorded on the profile page of the user, but that appears to be the only way to disable email that I can see. Thank you @peregrine your comment about blocking it while it gets written to activity helped me find this.

  • peregrineperegrine MVP
    edited March 2013

    @kirkpa31 said:
    well changing

    // Record the activity. if ($QnA == 'Accepted') { AddActivity( Gdn::Session()->UserID, 'AnswerAccepted', Anchor(Gdn_Format::Text($Discussion['Name']), "/discussion/{$Discussion['DiscussionID']}/".Gdn_Format::Url($Discussion['Name'])), $Comment['InsertUserID'], "/discussion/comment/{$Comment['CommentID']}/#Comment_{$Comment['CommentID']}", TRUE ); } }

    from TRUE to FALSE disables email notifications while not disabling the popups on the page, but it also disables non-email notifications within the forum itself. No activity is recorded on the profile page of the user, but that appears to be the only way to disable email that I can see. Thank you peregrine your comment about blocking it while it gets written to activity helped me find this.

    glad you found it, saved me time looking :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • edited April 2013

    from TRUE to FALSE disables email notifications while not disabling the popups on the page, but it also disables non-email notifications within the forum itself. No activity is recorded on the profile page of the user, but that appears to be the only way to disable email that I can see

    Ok - I see the logic - But it has to be possible to be able to disable EMAIL notifications while not disabling Notifications WITHIN the forum (i.e. still have them show up under the "Notifications" tab in the profile page)

    This method prevents the acceptance from being recorded to activity - therefore disabling any notification associated w/ it.

  • edited April 2013

    May I submit the changes for review, and eventually have them added to the main plugin? They don't interfere with main logic, and I believe other people could use them. Thanks.

    Thanks, I'm issuing a Pull Request right now. I haven't thought about a global configuration setting for notifications, therefore my update only allows Users to choose if they want to receive the notification.

    @businessdad - I know this was awhile ago but this current plugin does not give this option. Do you know what happened? How to give users the option to receive notifications for accepted answers?

  • @chrisk22985 said:
    businessdad - I know this was awhile ago but this current plugin does not give this option. Do you know what happened? How to give users the option to receive notifications for accepted answers?

    I don't think that my changes were ever pulled into the main repository. You can have a look at my forked repository to see the changes. Just keep in mind that they were not made against the latest master, but against the latest version which was still compatible with Vanilla 2.0 (branch name is Working_with_Vanilla_2.0.18.x).

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    Well I suppose my solution did just remove the notification altogether.

    I think there is something overall buggy with notifications. I might just hide them in css for my forum.

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    @chrisk22985

    I'm assuming that you could achieve a solution to your email problem by adding a string within your config.php file

    something along the lines of:

    $Configuration['Preferences']['Email']['BookmarkComment']       = '1';
    $Configuration['Preferences']['Email']['WallComment']           = '0';
    $Configuration['Preferences']['Email']['ActivityComment']       = '0';
    $Configuration['Preferences']['Email']['DiscussionComment']     = '0';
    

    only for your Q&A plugin, so maybe,

    $Configuration['Preferences']['Email']['Q&A Accepted'] = '0';

    I can look into this, probably just by playing around with different combinations of words until something works - may take awhile - I suggest you keep playing with it too.

    EDIT

    And I see you've been active on this page as well

    http://vanillaforums.org/discussion/23411/email-notifications-going-crazy#latest

    so if you decide to work on this yourself instead of contracting out, I wish you well!

  • Having no luck taking the config.php route. Every test the user still receives an email notification.

  • @kirkpa31 You could search the source code for 'Preferences.Email' and it will list out all the different configurations used.

    No need to guess

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight

    @vrijvlinder made a list of everything that sends notifications in this post: http://vanillaforums.org/discussion/comment/179988/#Comment_179988 but the Q&A plugin is not referenced here, hence my need to guess.

Sign In or Register to comment.