private void UnsuspendUser(DiscourseUser user) { try { DiscourseClient.AdminUnsuspendUser(user.Id); } catch (Exception) { //Try to login again and retry DiscourseClient.Login(AppSettings.Get("DiscourseAdminUserName", ""), AppSettings.Get("DiscourseAdminPassword", "")); DiscourseClient.AdminUnsuspendUser(user.Id); } }
private void SuspendUser(DiscourseUser user) { try { DiscourseClient.AdminSuspendUser(user.Id, 365, AppSettings.GetString("DiscourseSuspensionReason")); } catch (Exception) { //Try to login again and retry DiscourseClient.Login(AppSettings.Get("DiscourseAdminUserName", ""), AppSettings.Get("DiscourseAdminPassword", "")); DiscourseClient.AdminSuspendUser(user.Id, 365, AppSettings.GetString("DiscourseSuspensionReason")); } }
private void UpdateDiscourseAccountStatus(DiscourseUser discourseUser, UserServiceResponse existingCustomerSubscription, int throttleRequestTime = 2000) { try { Thread.Sleep(throttleRequestTime); if ((discourseUser.NeedsApproval() || discourseUser.IsSuspended()) && existingCustomerSubscription.HasValidSubscription()) { Log.Info("Approving user '{0}'.".Fmt(discourseUser.Email)); ApproveUser(discourseUser); } } catch (Exception e) { Log.Error("Failed to update Discourse for user '{0}'. - {1}".Fmt(discourseUser.Email, e.Message)); } }
private UserServiceResponse GetDiscourseUserServiceStackSubscription(DiscourseUser discourseUser) { UserServiceResponse existingCustomerSubscription = null; try { existingCustomerSubscription = ServiceStackAccountClient.GetUserSubscription(discourseUser.Email); } catch (Exception e) { Log.Error("Failed to check user {0} subscription. Retrying... - {1}".Fmt(discourseUser.Username, e.Message)); try { existingCustomerSubscription = ServiceStackAccountClient.GetUserSubscription(discourseUser.Email); } catch (Exception ex) { Log.Error("Failed to check user {0} subscription. Cancelling sync. - {1}".Fmt(discourseUser.Username, ex.Message)); return(existingCustomerSubscription); } } return(existingCustomerSubscription); }
public static bool IsNotSuspended(this DiscourseUser user) { // user.Suspended == null also means not suspended. return(user.Suspended != true); }
public static bool IsSuspended(this DiscourseUser user) { return(user.Suspended == true); }
public static bool NeedsApproval(this DiscourseUser user) { return(!user.Approved); }