I'm trying to turn off all notificiatons for new users that join the community and have written code to use the In-Process API to loop round each notification setting and then make another call with the In-Process API to disable each setting in turn for that user. I'm passing null as the distribution type as I want to turn off both email and live notifications.
However whatever I try I don't seem to get an AdditionalInfo response back and I don't get any errors or warnings either.
I've tried running this code as the new user and as the "admin" account but neither of these return a response.
Am I doing something wrong here?
private void Events_AfterCreate(UserAfterCreateEventArgs e) { if (e.IsSystemAccount != null && e.IsSystemAccount.Value && e.Username == "Anonymous") return; UpdateUserNotificationSettings(e); } private void UpdateUserNotificationSettings(ReadOnlyUserEventArgsBase user) { if (user.IsSystemAccount.HasValue && user.IsSystemAccount.Value) return; if (!user.Id.HasValue) return; foreach (var notification in Apis.Get<Telligent.Evolution.Extensibility.Api.Version1.INotifications>().ListNotificationTypes()) { AdditionalInfo additionalInfo = new AdditionalInfo(); Apis.Get<IUsers>().RunAsUser(user.Username, () => { additionalInfo = Apis.Get<Telligent.Evolution.Extensibility.Api.Version1.INotifications>().UpdatePreference(notification.NotificationTypeId, null, false); }); var warnings = (additionalInfo?.Warnings?.Count > 0) ? additionalInfo.Warnings[0].Message : string.Empty; var errors = (additionalInfo?.Errors?.Count > 0) ? additionalInfo.Errors[0].Message : string.Empty; _eventLogService.Log($"Notification Setting: {notification.Name} updated for user : {user.Username} - updated? : { additionalInfo!=null && !additionalInfo.HasErrors()} - warnings: {warnings} - errors: {errors} "); } }