Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

How to stop sending notification email in a custom plugin

Hi

I created a plugin that requires notification. All works fine except it keeps sending email notification even if its turned off in the configuration. Is there something I missed? Please see details below...

This is how I defined it in the plugin...

In the structure I create a new activity type like this

 public function structure(){
       
       $activityModel = new ActivityModel();

       $activityModel->defineType(
           'JoinTeam',
           [
               'AllowComments'=>false,
               'ShowIcon'=>true,
               //%1=ActivityName(=actingusersname)
               //%2=ActivityNamePossessive
               //%3=RegardingName(=affectedusersname)
               //%4=RegardingNamePossessive
               //%5=LinktoRegardingName'sWall
               //%6=his/her
               //%7=he/she
               //%8=RouteCode&Route
               'ProfileHeadline'=>'%1$s joined your team.',
               'FullHeadline'=>'%1$s joined your team.',
               'RouteCode'=>'team',
               'Notify'=>'1',
               'Public'=>'0'
           ]
       );
}

then I call this in the setup and also set initial configuration

public function setup(){
   $this->structure();
   Gdn::config()->touch('Preferences.Popup.JoinTeam',1);
   Gdn::config()->touch('Preferences.Email.JoinTeam',0);
}

I add it in the preferences

 public function profileController_afterPreferencesDefined_handler($sender){
   $sender->Preferences['Notifications']['Email.JoinTeam']=t('Notify me when someone joins my team.');
   $sender->Preferences['Notifications']['Popup.JoinTeam']=t('Notify me whensomeone joins myteam.');
}

Then I call this method to send notification where $activityType = 'JoinTeam'

   function sendNotification($route,$userIdNotifier,$userIdReciever,$activityType){

       //Createanewactivity.
       $activityModel=newactivityModel();
       $activityID=$activityModel->add(
           $userIdNotifier,//ActivityUserID
           $activityType,//ActivityType
           '',
           $userIdReciever,//RegardingUserID
           '',//CommentActivityID
           $route,//Route
           ''//SendEmail
       );
   }

Comments

Sign In or Register to comment.