2019-06-14 16:14:24 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System Limited 2010-2018
|
|
|
|
*
|
|
|
|
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
|
|
|
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
|
|
|
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
|
|
|
*
|
|
|
|
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
|
|
|
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
|
|
|
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
|
|
|
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
|
|
|
* in every copy of the program you distribute.
|
|
|
|
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Web;
|
2019-08-01 08:47:15 +00:00
|
|
|
|
2020-02-17 08:58:14 +00:00
|
|
|
using ASC.Common;
|
2019-06-14 16:14:24 +00:00
|
|
|
using ASC.Common.Logging;
|
|
|
|
using ASC.Core;
|
2019-11-08 12:21:51 +00:00
|
|
|
using ASC.Core.Common.Settings;
|
2019-06-14 16:14:24 +00:00
|
|
|
using ASC.Core.Tenants;
|
|
|
|
using ASC.Core.Users;
|
|
|
|
using ASC.Notify.Model;
|
|
|
|
using ASC.Notify.Patterns;
|
|
|
|
using ASC.Notify.Recipients;
|
2020-01-23 08:52:07 +00:00
|
|
|
using ASC.Web.Core;
|
2019-08-02 10:25:33 +00:00
|
|
|
using ASC.Web.Core.Notify;
|
2019-06-14 16:14:24 +00:00
|
|
|
using ASC.Web.Core.PublicResources;
|
|
|
|
using ASC.Web.Core.Users;
|
|
|
|
using ASC.Web.Core.WhiteLabel;
|
|
|
|
using ASC.Web.Studio.Utility;
|
2020-01-15 15:22:43 +00:00
|
|
|
|
2019-11-08 12:21:51 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2019-09-17 12:42:32 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2019-10-17 15:55:35 +00:00
|
|
|
using Microsoft.Extensions.Options;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
namespace ASC.Web.Studio.Core.Notify
|
|
|
|
{
|
2020-10-27 15:34:22 +00:00
|
|
|
[Scope(Additional = typeof(StudioNotifyServiceExtension))]
|
2019-06-14 16:14:24 +00:00
|
|
|
public class StudioNotifyService
|
|
|
|
{
|
2019-08-02 10:25:33 +00:00
|
|
|
private readonly StudioNotifyServiceHelper client;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2020-06-29 09:32:43 +00:00
|
|
|
public static string EMailSenderName { get { return ASC.Core.Configuration.Constants.NotifyEMailSenderSysName; } }
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-10-31 11:28:30 +00:00
|
|
|
private UserManager UserManager { get; }
|
|
|
|
private StudioNotifyHelper StudioNotifyHelper { get; }
|
|
|
|
private TenantExtra TenantExtra { get; }
|
|
|
|
private AuthManager Authentication { get; }
|
|
|
|
private AuthContext AuthContext { get; }
|
2020-08-12 09:58:08 +00:00
|
|
|
private IConfiguration Configuration { get; }
|
2019-10-31 11:28:30 +00:00
|
|
|
private TenantManager TenantManager { get; }
|
|
|
|
private CoreBaseSettings CoreBaseSettings { get; }
|
|
|
|
private CommonLinkUtility CommonLinkUtility { get; }
|
|
|
|
private SetupInfo SetupInfo { get; }
|
|
|
|
private IServiceProvider ServiceProvider { get; }
|
2020-08-12 09:58:08 +00:00
|
|
|
private DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
|
|
|
|
private SettingsManager SettingsManager { get; }
|
|
|
|
private WebItemSecurity WebItemSecurity { get; }
|
2019-10-31 11:28:30 +00:00
|
|
|
private ILog Log { get; }
|
2019-09-09 12:56:33 +00:00
|
|
|
|
|
|
|
public StudioNotifyService(
|
2019-09-27 10:45:37 +00:00
|
|
|
UserManager userManager,
|
|
|
|
StudioNotifyHelper studioNotifyHelper,
|
2019-09-09 12:56:33 +00:00
|
|
|
StudioNotifyServiceHelper studioNotifyServiceHelper,
|
|
|
|
TenantExtra tenantExtra,
|
|
|
|
AuthManager authentication,
|
2019-09-13 11:18:27 +00:00
|
|
|
AuthContext authContext,
|
2019-11-08 12:21:51 +00:00
|
|
|
IConfiguration configuration,
|
2019-09-17 12:42:32 +00:00
|
|
|
TenantManager tenantManager,
|
2019-09-18 15:19:30 +00:00
|
|
|
CoreBaseSettings coreBaseSettings,
|
2019-09-19 15:55:44 +00:00
|
|
|
CommonLinkUtility commonLinkUtility,
|
2019-09-23 12:20:08 +00:00
|
|
|
SetupInfo setupInfo,
|
2019-09-24 10:32:12 +00:00
|
|
|
IServiceProvider serviceProvider,
|
2019-11-08 12:21:51 +00:00
|
|
|
DisplayUserSettingsHelper displayUserSettingsHelper,
|
|
|
|
SettingsManager settingsManager,
|
2020-01-23 08:52:07 +00:00
|
|
|
WebItemSecurity webItemSecurity,
|
2019-11-06 15:03:09 +00:00
|
|
|
IOptionsMonitor<ILog> option)
|
2019-09-09 12:56:33 +00:00
|
|
|
{
|
2019-10-17 15:55:35 +00:00
|
|
|
Log = option.Get("ASC.Notify");
|
2019-09-09 12:56:33 +00:00
|
|
|
client = studioNotifyServiceHelper;
|
|
|
|
TenantExtra = tenantExtra;
|
|
|
|
Authentication = authentication;
|
|
|
|
AuthContext = authContext;
|
2019-11-08 12:21:51 +00:00
|
|
|
Configuration = configuration;
|
2019-09-17 12:42:32 +00:00
|
|
|
TenantManager = tenantManager;
|
2019-09-18 15:19:30 +00:00
|
|
|
CoreBaseSettings = coreBaseSettings;
|
2019-09-19 15:55:44 +00:00
|
|
|
CommonLinkUtility = commonLinkUtility;
|
2019-09-23 12:20:08 +00:00
|
|
|
SetupInfo = setupInfo;
|
2019-09-17 12:42:32 +00:00
|
|
|
ServiceProvider = serviceProvider;
|
2019-11-08 12:21:51 +00:00
|
|
|
DisplayUserSettingsHelper = displayUserSettingsHelper;
|
|
|
|
SettingsManager = settingsManager;
|
2020-01-23 08:52:07 +00:00
|
|
|
WebItemSecurity = webItemSecurity;
|
2019-09-09 12:56:33 +00:00
|
|
|
UserManager = userManager;
|
|
|
|
StudioNotifyHelper = studioNotifyHelper;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendMsgToAdminAboutProfileUpdated()
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
client.SendNoticeAsync(Actions.SelfProfileUpdated, null);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendMsgToAdminFromNotAuthUser(string email, string message)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
client.SendNoticeAsync(Actions.UserMessageToAdmin, null, new TagValue(Tags.Body, message), new TagValue(Tags.UserEmail, email));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SendRequestTariff(bool license, string fname, string lname, string title, string email, string phone, string ctitle, string csize, string site, string message)
|
|
|
|
{
|
|
|
|
fname = (fname ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(fname)) throw new ArgumentNullException(nameof(fname));
|
2019-06-14 16:14:24 +00:00
|
|
|
lname = (lname ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(lname)) throw new ArgumentNullException(nameof(lname));
|
2019-06-14 16:14:24 +00:00
|
|
|
title = (title ?? "").Trim();
|
|
|
|
email = (email ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(email)) throw new ArgumentNullException(nameof(email));
|
2019-06-14 16:14:24 +00:00
|
|
|
phone = (phone ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(phone)) throw new ArgumentNullException(nameof(phone));
|
2019-06-14 16:14:24 +00:00
|
|
|
ctitle = (ctitle ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(ctitle)) throw new ArgumentNullException(nameof(ctitle));
|
2019-06-14 16:14:24 +00:00
|
|
|
csize = (csize ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(csize)) throw new ArgumentNullException(nameof(csize));
|
2019-06-14 16:14:24 +00:00
|
|
|
site = (site ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(site) && !CoreBaseSettings.CustomMode) throw new ArgumentNullException(nameof(site));
|
2019-06-14 16:14:24 +00:00
|
|
|
message = (message ?? "").Trim();
|
2022-01-24 10:49:00 +00:00
|
|
|
if (string.IsNullOrEmpty(message) && !CoreBaseSettings.CustomMode) throw new ArgumentNullException(nameof(message));
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2020-09-07 13:53:39 +00:00
|
|
|
var salesEmail = SettingsManager.LoadForDefaultTenant<AdditionalWhiteLabelSettings>().SalesEmail ?? SetupInfo.SalesEmail;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-21 13:46:30 +00:00
|
|
|
var recipient = (IRecipient)new DirectRecipient(AuthContext.CurrentAccount.ID.ToString(), string.Empty, new[] { salesEmail }, false);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(license ? Actions.RequestLicense : Actions.RequestTariff,
|
|
|
|
new[] { recipient },
|
|
|
|
new[] { "email.sender" },
|
|
|
|
new TagValue(Tags.UserName, fname),
|
|
|
|
new TagValue(Tags.UserLastName, lname),
|
|
|
|
new TagValue(Tags.UserPosition, title),
|
|
|
|
new TagValue(Tags.UserEmail, email),
|
|
|
|
new TagValue(Tags.Phone, phone),
|
|
|
|
new TagValue(Tags.Website, site),
|
|
|
|
new TagValue(Tags.CompanyTitle, ctitle),
|
|
|
|
new TagValue(Tags.CompanySize, csize),
|
|
|
|
new TagValue(Tags.Body, message));
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Voip
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendToAdminVoipWarning(double balance)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
client.SendNoticeAsync(Actions.VoipWarning, null, new TagValue(Tags.Body, balance));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendToAdminVoipBlocked()
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
client.SendNoticeAsync(Actions.VoipBlocked, null);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region User Password
|
|
|
|
|
2019-09-20 15:53:27 +00:00
|
|
|
public void UserPasswordChange(UserInfo userInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2020-09-18 14:45:59 +00:00
|
|
|
var hash = Authentication.GetUserPasswordStamp(userInfo.ID).ToString("s");
|
2020-10-30 09:49:37 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(userInfo.Email, ConfirmType.PasswordChange, hash, userInfo.ID);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonChangePassword;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-18 15:19:30 +00:00
|
|
|
var action = CoreBaseSettings.Personal
|
|
|
|
? (CoreBaseSettings.CustomMode ? Actions.PersonalCustomModePasswordChange : Actions.PersonalPasswordChange)
|
2019-06-14 16:14:24 +00:00
|
|
|
: Actions.PasswordChange;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(userInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region User Email
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
public void SendEmailChangeInstructions(UserInfo user, string email)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-19 15:55:44 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(email, ConfirmType.EmailChange, AuthContext.CurrentAccount.ID);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonChangeEmail;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-18 15:19:30 +00:00
|
|
|
var action = CoreBaseSettings.Personal
|
2021-05-24 17:41:31 +00:00
|
|
|
? (CoreBaseSettings.CustomMode ? Actions.PersonalCustomModeEmailChangeV115 : Actions.PersonalEmailChangeV115)
|
|
|
|
: Actions.EmailChangeV115;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl),
|
|
|
|
new TagValue(CommonTags.Culture, user.GetCulture().Name));
|
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
public void SendEmailActivationInstructions(UserInfo user, string email)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2021-03-22 15:56:04 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(email, ConfirmType.EmailActivation, null, user.ID);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonActivateEmail;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.ActivateEmail,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.InviteLink, confirmationUrl),
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.UserDisplayName, (user.DisplayUserName(DisplayUserSettingsHelper) ?? string.Empty).Trim()));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region MailServer
|
|
|
|
|
|
|
|
public void SendMailboxCreated(List<string> toEmails, string username, string address)
|
|
|
|
{
|
|
|
|
SendMailboxCreated(toEmails, username, address, null, null, -1, -1, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendMailboxCreated(List<string> toEmails, string username, string address, string server,
|
2021-11-16 17:40:15 +00:00
|
|
|
string encyption, int portImap, int portSmtp, string login, bool skipSettings = false)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
var tags = new List<ITagValue>
|
|
|
|
{
|
|
|
|
new TagValue(Tags.UserName, username ?? string.Empty),
|
|
|
|
new TagValue(Tags.Address, address ?? string.Empty)
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!skipSettings)
|
|
|
|
{
|
2022-01-14 13:12:37 +00:00
|
|
|
var link = $"{CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')}/addons/mail/#accounts/changepwd={address}";
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
tags.Add(new TagValue(Tags.MyStaffLink, link));
|
|
|
|
tags.Add(new TagValue(Tags.Server, server));
|
|
|
|
tags.Add(new TagValue(Tags.Encryption, encyption ?? string.Empty));
|
|
|
|
tags.Add(new TagValue(Tags.ImapPort, portImap.ToString(CultureInfo.InvariantCulture)));
|
|
|
|
tags.Add(new TagValue(Tags.SmtpPort, portSmtp.ToString(CultureInfo.InvariantCulture)));
|
|
|
|
tags.Add(new TagValue(Tags.Login, login));
|
|
|
|
}
|
|
|
|
|
2020-01-23 08:52:07 +00:00
|
|
|
client.SendNoticeToAsync(
|
|
|
|
skipSettings
|
|
|
|
? Actions.MailboxWithoutSettingsCreated
|
|
|
|
: Actions.MailboxCreated,
|
|
|
|
null,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(toEmails, false),
|
2021-03-21 14:51:49 +00:00
|
|
|
new[] { EMailSenderName });
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SendMailboxPasswordChanged(List<string> toEmails, string username, string address)
|
|
|
|
{
|
2020-01-23 08:52:07 +00:00
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.MailboxPasswordChanged,
|
|
|
|
null,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(toEmails, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.UserName, username ?? string.Empty),
|
|
|
|
new TagValue(Tags.Address, address ?? string.Empty));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
public void SendMsgMobilePhoneChange(UserInfo userInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-19 15:55:44 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(userInfo.Email.ToLower(), ConfirmType.PhoneActivation);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonChangePhone;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.PhoneChange,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(userInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl));
|
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
public void SendMsgTfaReset(UserInfo userInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-19 15:55:44 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(userInfo.Email.ToLower(), ConfirmType.TfaActivation);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonChangeTfa;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.TfaChange,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(userInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void UserHasJoin()
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2020-12-28 13:22:08 +00:00
|
|
|
if (!CoreBaseSettings.Personal)
|
|
|
|
{
|
|
|
|
client.SendNoticeAsync(Actions.UserHasJoin, null);
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 12:14:15 +00:00
|
|
|
public void SendJoinMsg(string email, EmployeeType emplType)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2020-01-23 08:52:07 +00:00
|
|
|
var inviteUrl = CommonLinkUtility.GetConfirmationUrl(email, ConfirmType.EmpInvite, (int)emplType)
|
|
|
|
+ string.Format("&emplType={0}", (int)emplType);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonJoin;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.JoinUsers,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(email, true),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.InviteLink, inviteUrl),
|
2020-01-23 08:52:07 +00:00
|
|
|
TagValues.GreenButton(greenButtonText, inviteUrl));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-20 15:53:27 +00:00
|
|
|
public void UserInfoAddedAfterInvite(UserInfo newUserInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-09 12:56:33 +00:00
|
|
|
if (!UserManager.UserExists(newUserInfo)) return;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
INotifyAction notifyAction;
|
|
|
|
var footer = "social";
|
|
|
|
|
2019-09-18 15:19:30 +00:00
|
|
|
if (CoreBaseSettings.Personal)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-18 15:19:30 +00:00
|
|
|
if (CoreBaseSettings.CustomMode)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
notifyAction = Actions.PersonalCustomModeAfterRegistration1;
|
|
|
|
footer = "personalCustomMode";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
notifyAction = Actions.PersonalAfterRegistration1;
|
|
|
|
footer = "personal";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (TenantExtra.Enterprise)
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(SettingsManager, Configuration);
|
2019-06-14 16:14:24 +00:00
|
|
|
notifyAction = defaultRebranding
|
|
|
|
? Actions.EnterpriseUserWelcomeV10
|
2019-09-18 15:19:30 +00:00
|
|
|
: CoreBaseSettings.CustomMode
|
2019-06-14 16:14:24 +00:00
|
|
|
? Actions.EnterpriseWhitelabelUserWelcomeCustomMode
|
|
|
|
: Actions.EnterpriseWhitelabelUserWelcomeV10;
|
|
|
|
footer = null;
|
|
|
|
}
|
2020-09-18 14:45:59 +00:00
|
|
|
else if (TenantExtra.Opensource)
|
|
|
|
{
|
|
|
|
notifyAction = Actions.OpensourceUserWelcomeV11;
|
|
|
|
footer = "opensource";
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
else
|
|
|
|
{
|
2021-05-24 17:41:31 +00:00
|
|
|
notifyAction = Actions.SaasUserWelcomeV115;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 12:56:33 +00:00
|
|
|
string greenButtonText() => TenantExtra.Enterprise
|
2019-06-14 16:14:24 +00:00
|
|
|
? WebstudioNotifyPatternResource.ButtonAccessYourPortal
|
|
|
|
: WebstudioNotifyPatternResource.ButtonAccessYouWebOffice;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
notifyAction,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(newUserInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.UserName, newUserInfo.FirstName.HtmlEncode()),
|
|
|
|
new TagValue(Tags.MyStaffLink, GetMyStaffLink()),
|
|
|
|
TagValues.GreenButton(greenButtonText, CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')),
|
|
|
|
new TagValue(CommonTags.Footer, footer),
|
2020-12-28 13:22:08 +00:00
|
|
|
new TagValue(CommonTags.MasterTemplate, CoreBaseSettings.Personal ? "HtmlMasterPersonal" : "HtmlMaster"));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-08-30 12:40:57 +00:00
|
|
|
public void GuestInfoAddedAfterInvite(UserInfo newUserInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-09 12:56:33 +00:00
|
|
|
if (!UserManager.UserExists(newUserInfo)) return;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
INotifyAction notifyAction;
|
|
|
|
var footer = "social";
|
|
|
|
|
|
|
|
if (TenantExtra.Enterprise)
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(SettingsManager, Configuration);
|
2019-06-14 16:14:24 +00:00
|
|
|
notifyAction = defaultRebranding ? Actions.EnterpriseGuestWelcomeV10 : Actions.EnterpriseWhitelabelGuestWelcomeV10;
|
|
|
|
footer = null;
|
|
|
|
}
|
2020-09-18 14:45:59 +00:00
|
|
|
else if (TenantExtra.Opensource)
|
|
|
|
{
|
|
|
|
notifyAction = Actions.OpensourceGuestWelcomeV11;
|
|
|
|
footer = "opensource";
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
else
|
|
|
|
{
|
2021-05-24 17:41:31 +00:00
|
|
|
notifyAction = Actions.SaasGuestWelcomeV115;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 12:56:33 +00:00
|
|
|
string greenButtonText() => TenantExtra.Enterprise
|
2019-06-14 16:14:24 +00:00
|
|
|
? WebstudioNotifyPatternResource.ButtonAccessYourPortal
|
|
|
|
: WebstudioNotifyPatternResource.ButtonAccessYouWebOffice;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
notifyAction,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(newUserInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.UserName, newUserInfo.FirstName.HtmlEncode()),
|
|
|
|
new TagValue(Tags.MyStaffLink, GetMyStaffLink()),
|
|
|
|
TagValues.GreenButton(greenButtonText, CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')),
|
2020-12-28 13:22:08 +00:00
|
|
|
new TagValue(CommonTags.Footer, footer));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-20 15:53:27 +00:00
|
|
|
public void UserInfoActivation(UserInfo newUserInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
if (newUserInfo.IsActive)
|
|
|
|
throw new ArgumentException("User is already activated!");
|
|
|
|
|
|
|
|
INotifyAction notifyAction;
|
|
|
|
var footer = "social";
|
|
|
|
|
|
|
|
if (TenantExtra.Enterprise)
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(SettingsManager, Configuration);
|
2019-06-14 16:14:24 +00:00
|
|
|
notifyAction = defaultRebranding ? Actions.EnterpriseUserActivationV10 : Actions.EnterpriseWhitelabelUserActivationV10;
|
|
|
|
footer = null;
|
|
|
|
}
|
2020-09-18 14:45:59 +00:00
|
|
|
else if (TenantExtra.Opensource)
|
|
|
|
{
|
|
|
|
notifyAction = Actions.OpensourceUserActivationV11;
|
|
|
|
footer = "opensource";
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
else
|
|
|
|
{
|
2021-05-24 17:41:31 +00:00
|
|
|
notifyAction = Actions.SaasUserActivationV115;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
var confirmationUrl = GenerateActivationConfirmUrl(newUserInfo);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonAccept;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
notifyAction,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(newUserInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
2020-09-18 14:45:59 +00:00
|
|
|
new TagValue(Tags.ActivateUrl, confirmationUrl),
|
2019-06-14 16:14:24 +00:00
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl),
|
|
|
|
new TagValue(Tags.UserName, newUserInfo.FirstName.HtmlEncode()),
|
2020-12-28 13:22:08 +00:00
|
|
|
new TagValue(CommonTags.Footer, footer));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-20 15:53:27 +00:00
|
|
|
public void GuestInfoActivation(UserInfo newUserInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
if (newUserInfo.IsActive)
|
|
|
|
throw new ArgumentException("User is already activated!");
|
|
|
|
|
|
|
|
INotifyAction notifyAction;
|
|
|
|
var footer = "social";
|
|
|
|
|
|
|
|
if (TenantExtra.Enterprise)
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(SettingsManager, Configuration);
|
2019-06-14 16:14:24 +00:00
|
|
|
notifyAction = defaultRebranding ? Actions.EnterpriseGuestActivationV10 : Actions.EnterpriseWhitelabelGuestActivationV10;
|
|
|
|
footer = null;
|
|
|
|
}
|
2020-09-18 14:45:59 +00:00
|
|
|
else if (TenantExtra.Opensource)
|
|
|
|
{
|
|
|
|
notifyAction = Actions.OpensourceGuestActivationV11;
|
|
|
|
footer = "opensource";
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
else
|
|
|
|
{
|
2021-05-24 17:41:31 +00:00
|
|
|
notifyAction = Actions.SaasGuestActivationV115;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
var confirmationUrl = GenerateActivationConfirmUrl(newUserInfo);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonAccept;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
notifyAction,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(newUserInfo.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
2020-09-18 14:45:59 +00:00
|
|
|
new TagValue(Tags.ActivateUrl, confirmationUrl),
|
2019-06-14 16:14:24 +00:00
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl),
|
|
|
|
new TagValue(Tags.UserName, newUserInfo.FirstName.HtmlEncode()),
|
2020-12-28 13:22:08 +00:00
|
|
|
new TagValue(CommonTags.Footer, footer));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
public void SendMsgProfileDeletion(UserInfo user)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-10-30 08:45:55 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.ProfileRemove, AuthContext.CurrentAccount.ID, AuthContext.CurrentAccount.ID);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-18 15:19:30 +00:00
|
|
|
string greenButtonText() => CoreBaseSettings.Personal ? WebstudioNotifyPatternResource.ButtonConfirmTermination : WebstudioNotifyPatternResource.ButtonRemoveProfile;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-18 15:19:30 +00:00
|
|
|
var action = CoreBaseSettings.Personal
|
|
|
|
? (CoreBaseSettings.CustomMode ? Actions.PersonalCustomModeProfileDelete : Actions.PersonalProfileDelete)
|
2019-06-14 16:14:24 +00:00
|
|
|
: Actions.ProfileDelete;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(user.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl),
|
|
|
|
new TagValue(CommonTags.Culture, user.GetCulture().Name));
|
|
|
|
}
|
|
|
|
|
2020-01-23 08:52:07 +00:00
|
|
|
public void SendMsgProfileHasDeletedItself(UserInfo user)
|
|
|
|
{
|
|
|
|
var tenant = TenantManager.GetCurrentTenant();
|
|
|
|
var admins = UserManager.GetUsers()
|
|
|
|
.Where(u => WebItemSecurity.IsProductAdministrator(WebItemManager.PeopleProductID, u.ID));
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
ThreadPool.QueueUserWorkItem(_ =>
|
2020-01-23 08:52:07 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
TenantManager.SetCurrentTenant(tenant);
|
|
|
|
|
|
|
|
foreach (var admin in admins)
|
|
|
|
{
|
|
|
|
var culture = string.IsNullOrEmpty(admin.CultureName) ? tenant.GetCulture() : admin.GetCulture();
|
|
|
|
Thread.CurrentThread.CurrentCulture = culture;
|
|
|
|
Thread.CurrentThread.CurrentUICulture = culture;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.ProfileHasDeletedItself,
|
|
|
|
null,
|
|
|
|
new IRecipient[] { admin },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.FromUserName, user.DisplayUserName(DisplayUserSettingsHelper)),
|
|
|
|
new TagValue(Tags.FromUserLink, GetUserProfileLink(user)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Log.Error(ex);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendMsgReassignsCompleted(Guid recipientId, UserInfo fromUser, UserInfo toUser)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.ReassignsCompleted,
|
2019-09-12 11:34:58 +00:00
|
|
|
new[] { StudioNotifyHelper.ToRecipient(recipientId) },
|
2019-06-14 16:14:24 +00:00
|
|
|
new[] { EMailSenderName },
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.UserName, DisplayUserSettingsHelper.GetFullUserName(recipientId)),
|
|
|
|
new TagValue(Tags.FromUserName, fromUser.DisplayUserName(DisplayUserSettingsHelper)),
|
2019-09-19 15:55:44 +00:00
|
|
|
new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUser)),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.ToUserName, toUser.DisplayUserName(DisplayUserSettingsHelper)),
|
2019-09-19 15:55:44 +00:00
|
|
|
new TagValue(Tags.ToUserLink, GetUserProfileLink(toUser)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendMsgReassignsFailed(Guid recipientId, UserInfo fromUser, UserInfo toUser, string message)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.ReassignsFailed,
|
2019-09-12 11:34:58 +00:00
|
|
|
new[] { StudioNotifyHelper.ToRecipient(recipientId) },
|
2019-06-14 16:14:24 +00:00
|
|
|
new[] { EMailSenderName },
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.UserName, DisplayUserSettingsHelper.GetFullUserName(recipientId)),
|
|
|
|
new TagValue(Tags.FromUserName, fromUser.DisplayUserName(DisplayUserSettingsHelper)),
|
2019-09-19 15:55:44 +00:00
|
|
|
new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUser)),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.ToUserName, toUser.DisplayUserName(DisplayUserSettingsHelper)),
|
2019-09-19 15:55:44 +00:00
|
|
|
new TagValue(Tags.ToUserLink, GetUserProfileLink(toUser)),
|
2019-06-14 16:14:24 +00:00
|
|
|
new TagValue(Tags.Message, message));
|
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendMsgRemoveUserDataCompleted(Guid recipientId, UserInfo user, string fromUserName, long docsSpace, long crmSpace, long mailSpace, long talkSpace)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
client.SendNoticeToAsync(
|
2019-09-19 11:34:54 +00:00
|
|
|
CoreBaseSettings.CustomMode ? Actions.RemoveUserDataCompletedCustomMode : Actions.RemoveUserDataCompleted,
|
2019-09-12 11:34:58 +00:00
|
|
|
new[] { StudioNotifyHelper.ToRecipient(recipientId) },
|
2019-06-14 16:14:24 +00:00
|
|
|
new[] { EMailSenderName },
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.UserName, DisplayUserSettingsHelper.GetFullUserName(recipientId)),
|
2019-06-14 16:14:24 +00:00
|
|
|
new TagValue(Tags.FromUserName, fromUserName.HtmlEncode()),
|
2019-09-19 15:55:44 +00:00
|
|
|
new TagValue(Tags.FromUserLink, GetUserProfileLink(user)),
|
2019-06-14 16:14:24 +00:00
|
|
|
new TagValue("DocsSpace", FileSizeComment.FilesSizeToString(docsSpace)),
|
|
|
|
new TagValue("CrmSpace", FileSizeComment.FilesSizeToString(crmSpace)),
|
|
|
|
new TagValue("MailSpace", FileSizeComment.FilesSizeToString(mailSpace)),
|
|
|
|
new TagValue("TalkSpace", FileSizeComment.FilesSizeToString(talkSpace)));
|
|
|
|
}
|
|
|
|
|
2019-09-12 11:34:58 +00:00
|
|
|
public void SendMsgRemoveUserDataFailed(Guid recipientId, UserInfo user, string fromUserName, string message)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.RemoveUserDataFailed,
|
2019-09-12 11:34:58 +00:00
|
|
|
new[] { StudioNotifyHelper.ToRecipient(recipientId) },
|
2019-06-14 16:14:24 +00:00
|
|
|
new[] { EMailSenderName },
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.UserName, DisplayUserSettingsHelper.GetFullUserName(recipientId)),
|
2019-06-14 16:14:24 +00:00
|
|
|
new TagValue(Tags.FromUserName, fromUserName.HtmlEncode()),
|
2019-09-19 15:55:44 +00:00
|
|
|
new TagValue(Tags.FromUserLink, GetUserProfileLink(user)),
|
2019-06-14 16:14:24 +00:00
|
|
|
new TagValue(Tags.Message, message));
|
|
|
|
}
|
|
|
|
|
2019-09-18 12:14:15 +00:00
|
|
|
public void SendAdminWelcome(UserInfo newUserInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-09 12:56:33 +00:00
|
|
|
if (!UserManager.UserExists(newUserInfo)) return;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
if (!newUserInfo.IsActive)
|
|
|
|
throw new ArgumentException("User is not activated yet!");
|
|
|
|
|
|
|
|
INotifyAction notifyAction;
|
|
|
|
var tagValues = new List<ITagValue>();
|
|
|
|
|
|
|
|
if (TenantExtra.Enterprise)
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(SettingsManager, Configuration);
|
2019-06-14 16:14:24 +00:00
|
|
|
notifyAction = defaultRebranding ? Actions.EnterpriseAdminWelcomeV10 : Actions.EnterpriseWhitelabelAdminWelcomeV10;
|
|
|
|
|
2020-09-18 14:45:59 +00:00
|
|
|
tagValues.Add(TagValues.GreenButton(() => WebstudioNotifyPatternResource.ButtonAccessControlPanel, CommonLinkUtility.GetFullAbsolutePath(SetupInfo.ControlPanelUrl)));
|
|
|
|
}
|
|
|
|
else if (TenantExtra.Opensource)
|
|
|
|
{
|
|
|
|
notifyAction = Actions.OpensourceAdminWelcomeV11;
|
|
|
|
tagValues.Add(new TagValue(CommonTags.Footer, "opensource"));
|
|
|
|
tagValues.Add(new TagValue(Tags.ControlPanelUrl, CommonLinkUtility.GetFullAbsolutePath(SetupInfo.ControlPanelUrl).TrimEnd('/')));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-24 17:41:31 +00:00
|
|
|
notifyAction = Actions.SaasAdminWelcomeV115;
|
|
|
|
//tagValues.Add(TagValues.GreenButton(() => WebstudioNotifyPatternResource.ButtonConfigureRightNow, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetAdministration(ManagementType.General))));
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
tagValues.Add(new TagValue(CommonTags.Footer, "common"));
|
|
|
|
}
|
|
|
|
|
|
|
|
tagValues.Add(new TagValue(Tags.UserName, newUserInfo.FirstName.HtmlEncode()));
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
notifyAction,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(newUserInfo.Email, false),
|
2019-08-15 12:04:42 +00:00
|
|
|
new[] { EMailSenderName },
|
2019-06-14 16:14:24 +00:00
|
|
|
tagValues.ToArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Portal Deactivation & Deletion
|
|
|
|
|
|
|
|
public void SendMsgPortalDeactivation(Tenant t, string deactivateUrl, string activateUrl)
|
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
var u = UserManager.GetUsers(t.OwnerId);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonDeactivatePortal;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.PortalDeactivate,
|
|
|
|
new IRecipient[] { u },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.ActivateUrl, activateUrl),
|
|
|
|
TagValues.GreenButton(greenButtonText, deactivateUrl),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.OwnerName, u.DisplayUserName(DisplayUserSettingsHelper)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SendMsgPortalDeletion(Tenant t, string url, bool showAutoRenewText)
|
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
var u = UserManager.GetUsers(t.OwnerId);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonDeletePortal;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.PortalDelete,
|
|
|
|
new IRecipient[] { u },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, url),
|
|
|
|
new TagValue(Tags.AutoRenew, showAutoRenewText.ToString()),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.OwnerName, u.DisplayUserName(DisplayUserSettingsHelper)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SendMsgPortalDeletionSuccess(UserInfo owner, string url)
|
|
|
|
{
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonLeaveFeedback;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
2021-05-24 17:41:31 +00:00
|
|
|
Actions.PortalDeleteSuccessV115,
|
2019-06-14 16:14:24 +00:00
|
|
|
new IRecipient[] { owner },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, url),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.OwnerName, owner.DisplayUserName(DisplayUserSettingsHelper)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public void SendMsgDnsChange(Tenant t, string confirmDnsUpdateUrl, string portalAddress, string portalDns)
|
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
var u = UserManager.GetUsers(t.OwnerId);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonConfirmPortalAddressChange;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.DnsChange,
|
|
|
|
new IRecipient[] { u },
|
|
|
|
new[] { EMailSenderName },
|
2020-01-23 08:52:07 +00:00
|
|
|
new TagValue("ConfirmDnsUpdate", confirmDnsUpdateUrl),//TODO: Tag is deprecated and replaced by TagGreenButton
|
2019-06-14 16:14:24 +00:00
|
|
|
TagValues.GreenButton(greenButtonText, confirmDnsUpdateUrl),
|
|
|
|
new TagValue("PortalAddress", AddHttpToUrl(portalAddress)),
|
|
|
|
new TagValue("PortalDns", AddHttpToUrl(portalDns ?? string.Empty)),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.OwnerName, u.DisplayUserName(DisplayUserSettingsHelper)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 15:22:43 +00:00
|
|
|
public void SendMsgConfirmChangeOwner(UserInfo owner, UserInfo newOwner, string confirmOwnerUpdateUrl)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonConfirmPortalOwnerUpdate;
|
2019-08-15 12:04:42 +00:00
|
|
|
|
2019-06-14 16:14:24 +00:00
|
|
|
client.SendNoticeToAsync(
|
2020-01-15 15:22:43 +00:00
|
|
|
Actions.ConfirmOwnerChange,
|
|
|
|
null,
|
|
|
|
new IRecipient[] { owner },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
TagValues.GreenButton(greenButtonText, confirmOwnerUpdateUrl),
|
|
|
|
new TagValue(Tags.UserName, newOwner.DisplayUserName(DisplayUserSettingsHelper)),
|
|
|
|
new TagValue(Tags.OwnerName, owner.DisplayUserName(DisplayUserSettingsHelper)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
public void SendCongratulations(UserInfo u)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
INotifyAction notifyAction;
|
|
|
|
var footer = "common";
|
|
|
|
|
|
|
|
if (TenantExtra.Enterprise)
|
|
|
|
{
|
2019-11-08 12:21:51 +00:00
|
|
|
var defaultRebranding = MailWhiteLabelSettings.IsDefault(SettingsManager, Configuration);
|
2019-06-14 16:14:24 +00:00
|
|
|
notifyAction = defaultRebranding ? Actions.EnterpriseAdminActivationV10 : Actions.EnterpriseWhitelabelAdminActivationV10;
|
|
|
|
footer = null;
|
|
|
|
}
|
|
|
|
else if (TenantExtra.Opensource)
|
|
|
|
{
|
2020-09-18 14:45:59 +00:00
|
|
|
notifyAction = Actions.OpensourceAdminActivationV11;
|
2019-06-14 16:14:24 +00:00
|
|
|
footer = "opensource";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-24 17:41:31 +00:00
|
|
|
notifyAction = Actions.SaasAdminActivationV115;
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-19 15:55:44 +00:00
|
|
|
var confirmationUrl = CommonLinkUtility.GetConfirmationUrl(u.Email, ConfirmType.EmailActivation);
|
2019-06-14 16:14:24 +00:00
|
|
|
confirmationUrl += "&first=true";
|
|
|
|
|
2022-01-10 15:13:30 +00:00
|
|
|
string greenButtonText() => WebstudioNotifyPatternResource.ButtonConfirm;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
notifyAction,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(u.Email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.UserName, u.FirstName.HtmlEncode()),
|
|
|
|
new TagValue(Tags.MyStaffLink, GetMyStaffLink()),
|
2020-09-18 14:45:59 +00:00
|
|
|
new TagValue(Tags.ActivateUrl, confirmationUrl),
|
2019-06-14 16:14:24 +00:00
|
|
|
TagValues.GreenButton(greenButtonText, confirmationUrl),
|
2020-12-28 13:22:08 +00:00
|
|
|
new TagValue(CommonTags.Footer, footer));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
catch (Exception error)
|
|
|
|
{
|
2019-10-17 15:55:35 +00:00
|
|
|
Log.Error(error);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Personal
|
|
|
|
|
2020-12-28 13:22:08 +00:00
|
|
|
public void SendInvitePersonal(string email, string additionalMember = "")
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-27 10:45:37 +00:00
|
|
|
var newUserInfo = UserManager.GetUserByEmail(email);
|
2019-09-09 12:56:33 +00:00
|
|
|
if (UserManager.UserExists(newUserInfo)) return;
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-18 15:19:30 +00:00
|
|
|
var lang = CoreBaseSettings.CustomMode
|
2019-06-14 16:14:24 +00:00
|
|
|
? "ru-RU"
|
2021-11-16 17:40:15 +00:00
|
|
|
: Thread.CurrentThread.CurrentUICulture.Name;
|
|
|
|
|
|
|
|
var culture = SetupInfo.GetPersonalCulture(lang);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-19 15:55:44 +00:00
|
|
|
var confirmUrl = CommonLinkUtility.GetConfirmationUrl(email, ConfirmType.EmpInvite, (int)EmployeeType.User)
|
2019-06-14 16:14:24 +00:00
|
|
|
+ "&emplType=" + (int)EmployeeType.User
|
2021-11-16 17:40:15 +00:00
|
|
|
+ "&lang=" + culture.Key
|
2019-06-14 16:14:24 +00:00
|
|
|
+ additionalMember;
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
2019-09-18 15:19:30 +00:00
|
|
|
CoreBaseSettings.CustomMode ? Actions.PersonalCustomModeConfirmation : Actions.PersonalConfirmation,
|
2019-06-14 16:14:24 +00:00
|
|
|
StudioNotifyHelper.RecipientFromEmail(email, false),
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.InviteLink, confirmUrl),
|
2019-09-18 15:19:30 +00:00
|
|
|
new TagValue(CommonTags.Footer, CoreBaseSettings.CustomMode ? "personalCustomMode" : "personal"),
|
2019-06-14 16:14:24 +00:00
|
|
|
new TagValue(CommonTags.Culture, Thread.CurrentThread.CurrentUICulture.Name));
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:17:06 +00:00
|
|
|
public void SendAlreadyExist(string email)
|
|
|
|
{
|
|
|
|
var userInfo = UserManager.GetUserByEmail(email);
|
|
|
|
if (!UserManager.UserExists(userInfo)) return;
|
|
|
|
|
2021-11-30 09:09:51 +00:00
|
|
|
var portalUrl = CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/');
|
|
|
|
|
|
|
|
var hash = Authentication.GetUserPasswordStamp(userInfo.ID).ToString("s");
|
|
|
|
|
|
|
|
var linkToRecovery = CommonLinkUtility.GetConfirmationUrl(userInfo.Email, ConfirmType.PasswordChange, hash, userInfo.ID);
|
|
|
|
|
2021-09-28 12:17:06 +00:00
|
|
|
client.SendNoticeToAsync(
|
|
|
|
CoreBaseSettings.CustomMode ? Actions.PersonalCustomModeAlreadyExist : Actions.PersonalAlreadyExist,
|
|
|
|
StudioNotifyHelper.RecipientFromEmail(email, false),
|
|
|
|
new[] { EMailSenderName },
|
2021-11-30 09:09:51 +00:00
|
|
|
new TagValue(Tags.PortalUrl, portalUrl),
|
|
|
|
new TagValue(Tags.LinkToRecovery, linkToRecovery),
|
2021-09-28 12:17:06 +00:00
|
|
|
new TagValue(CommonTags.Footer, CoreBaseSettings.CustomMode ? "personalCustomMode" : "personal"),
|
|
|
|
new TagValue(CommonTags.Culture, Thread.CurrentThread.CurrentUICulture.Name));
|
|
|
|
}
|
|
|
|
|
2019-09-18 12:14:15 +00:00
|
|
|
public void SendUserWelcomePersonal(UserInfo newUserInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
client.SendNoticeToAsync(
|
2019-09-18 15:19:30 +00:00
|
|
|
CoreBaseSettings.CustomMode ? Actions.PersonalCustomModeAfterRegistration1 : Actions.PersonalAfterRegistration1,
|
2019-06-14 16:14:24 +00:00
|
|
|
StudioNotifyHelper.RecipientFromEmail(newUserInfo.Email, true),
|
|
|
|
new[] { EMailSenderName },
|
2019-09-18 15:19:30 +00:00
|
|
|
new TagValue(CommonTags.Footer, CoreBaseSettings.CustomMode ? "personalCustomMode" : "personal"),
|
2020-01-23 08:52:07 +00:00
|
|
|
new TagValue(CommonTags.MasterTemplate, "HtmlMasterPersonal"));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Migration Portal
|
|
|
|
|
2019-08-15 13:16:39 +00:00
|
|
|
public void PortalRenameNotify(Tenant tenant, string oldVirtualRootPath)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-12 11:34:58 +00:00
|
|
|
var users = UserManager.GetUsers()
|
2019-06-14 16:14:24 +00:00
|
|
|
.Where(u => u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated));
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
ThreadPool.QueueUserWorkItem(_ =>
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2019-09-17 12:42:32 +00:00
|
|
|
var scope = ServiceProvider.CreateScope();
|
2020-08-24 18:41:06 +00:00
|
|
|
var scopeClass = scope.ServiceProvider.GetService<StudioNotifyServiceScope>();
|
2020-09-07 12:01:15 +00:00
|
|
|
var (tenantManager, studioNotifyServiceHelper) = scopeClass;
|
2020-08-31 08:18:07 +00:00
|
|
|
tenantManager.SetCurrentTenant(tenant);
|
2019-09-18 15:19:30 +00:00
|
|
|
|
2019-06-14 16:14:24 +00:00
|
|
|
foreach (var u in users)
|
|
|
|
{
|
|
|
|
var culture = string.IsNullOrEmpty(u.CultureName) ? tenant.GetCulture() : u.GetCulture();
|
|
|
|
Thread.CurrentThread.CurrentCulture = culture;
|
|
|
|
Thread.CurrentThread.CurrentUICulture = culture;
|
|
|
|
|
2020-08-31 08:18:07 +00:00
|
|
|
studioNotifyServiceHelper.SendNoticeToAsync(
|
2019-06-14 16:14:24 +00:00
|
|
|
Actions.PortalRename,
|
2019-09-12 11:34:58 +00:00
|
|
|
new[] { StudioNotifyHelper.ToRecipient(u.ID) },
|
2019-06-14 16:14:24 +00:00
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.PortalUrl, oldVirtualRootPath),
|
2019-11-08 12:21:51 +00:00
|
|
|
new TagValue(Tags.UserDisplayName, u.DisplayUserName(DisplayUserSettingsHelper)));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2019-10-17 15:55:35 +00:00
|
|
|
Log.Error(ex);
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Helpers
|
|
|
|
|
2019-09-19 11:34:54 +00:00
|
|
|
private string GetMyStaffLink()
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-19 15:55:44 +00:00
|
|
|
return CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetMyStaff());
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 10:45:37 +00:00
|
|
|
private string GetUserProfileLink(UserInfo userInfo)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-19 15:55:44 +00:00
|
|
|
return CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(userInfo));
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static string AddHttpToUrl(string url)
|
|
|
|
{
|
|
|
|
var httpPrefix = Uri.UriSchemeHttp + Uri.SchemeDelimiter;
|
|
|
|
return !string.IsNullOrEmpty(url) && !url.StartsWith(httpPrefix) ? httpPrefix + url : url;
|
|
|
|
}
|
|
|
|
|
2019-09-17 12:42:32 +00:00
|
|
|
private string GenerateActivationConfirmUrl(UserInfo user)
|
2019-06-14 16:14:24 +00:00
|
|
|
{
|
2019-09-27 10:45:37 +00:00
|
|
|
var confirmUrl = CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.Activation, user.ID, user.ID);
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2019-09-27 14:49:45 +00:00
|
|
|
return confirmUrl + $"&firstname={HttpUtility.UrlEncode(user.FirstName)}&lastname={HttpUtility.UrlEncode(user.LastName)}";
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2020-09-11 14:12:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
public void SendRegData(UserInfo u)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!TenantExtra.Saas || !CoreBaseSettings.CustomMode) return;
|
|
|
|
|
|
|
|
var settings = SettingsManager.LoadForDefaultTenant<AdditionalWhiteLabelSettings>();
|
|
|
|
var salesEmail = settings.SalesEmail ?? SetupInfo.SalesEmail;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(salesEmail)) return;
|
|
|
|
|
|
|
|
var recipient = new DirectRecipient(salesEmail, null, new[] { salesEmail }, false);
|
|
|
|
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
Actions.SaasCustomModeRegData,
|
|
|
|
null,
|
|
|
|
new IRecipient[] { recipient },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.UserName, u.FirstName.HtmlEncode()),
|
2020-09-18 14:45:59 +00:00
|
|
|
new TagValue(Tags.UserLastName, u.LastName.HtmlEncode()),
|
2020-09-11 14:12:35 +00:00
|
|
|
new TagValue(Tags.UserEmail, u.Email.HtmlEncode()),
|
|
|
|
new TagValue(Tags.Phone, u.MobilePhone != null ? u.MobilePhone.HtmlEncode() : "-"),
|
|
|
|
new TagValue(Tags.Date, u.CreateDate.ToShortDateString() + " " + u.CreateDate.ToShortTimeString()),
|
|
|
|
new TagValue(CommonTags.Footer, null),
|
|
|
|
TagValues.WithoutUnsubscribe());
|
|
|
|
}
|
|
|
|
catch (Exception error)
|
|
|
|
{
|
|
|
|
Log.Error(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-24 18:41:06 +00:00
|
|
|
#endregion
|
2020-09-16 10:50:53 +00:00
|
|
|
|
|
|
|
#region Storage encryption
|
|
|
|
|
|
|
|
public void SendStorageEncryptionStart(string serverRootPath)
|
|
|
|
{
|
|
|
|
SendStorageEncryptionNotify(Actions.StorageEncryptionStart, false, serverRootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendStorageEncryptionSuccess(string serverRootPath)
|
|
|
|
{
|
|
|
|
SendStorageEncryptionNotify(Actions.StorageEncryptionSuccess, false, serverRootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendStorageEncryptionError(string serverRootPath)
|
|
|
|
{
|
|
|
|
SendStorageEncryptionNotify(Actions.StorageEncryptionError, true, serverRootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendStorageDecryptionStart(string serverRootPath)
|
|
|
|
{
|
|
|
|
SendStorageEncryptionNotify(Actions.StorageDecryptionStart, false, serverRootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendStorageDecryptionSuccess(string serverRootPath)
|
|
|
|
{
|
|
|
|
SendStorageEncryptionNotify(Actions.StorageDecryptionSuccess, false, serverRootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendStorageDecryptionError(string serverRootPath)
|
|
|
|
{
|
|
|
|
SendStorageEncryptionNotify(Actions.StorageDecryptionError, true, serverRootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SendStorageEncryptionNotify(INotifyAction action, bool notifyAdminsOnly, string serverRootPath)
|
|
|
|
{
|
|
|
|
var users = notifyAdminsOnly
|
|
|
|
? UserManager.GetUsersByGroup(Constants.GroupAdmin.ID)
|
|
|
|
: UserManager.GetUsers().Where(u => u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated));
|
|
|
|
|
|
|
|
foreach (var u in users)
|
|
|
|
{
|
|
|
|
client.SendNoticeToAsync(
|
|
|
|
action,
|
|
|
|
null,
|
|
|
|
new[] { StudioNotifyHelper.ToRecipient(u.ID) },
|
|
|
|
new[] { EMailSenderName },
|
|
|
|
new TagValue(Tags.UserName, u.FirstName.HtmlEncode()),
|
|
|
|
new TagValue(Tags.PortalUrl, serverRootPath),
|
|
|
|
new TagValue(Tags.ControlPanelUrl, GetControlPanelUrl(serverRootPath)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private string GetControlPanelUrl(string serverRootPath)
|
|
|
|
{
|
|
|
|
var controlPanelUrl = SetupInfo.ControlPanelUrl;
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(controlPanelUrl))
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
if (controlPanelUrl.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) ||
|
|
|
|
controlPanelUrl.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
return controlPanelUrl;
|
|
|
|
|
|
|
|
return serverRootPath + "/" + controlPanelUrl.TrimStart('~', '/').TrimEnd('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2020-08-24 18:41:06 +00:00
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
|
2020-10-27 15:34:22 +00:00
|
|
|
[Scope]
|
2020-08-24 18:41:06 +00:00
|
|
|
public class StudioNotifyServiceScope
|
|
|
|
{
|
2020-08-31 08:18:07 +00:00
|
|
|
private TenantManager TenantManager { get; }
|
|
|
|
private StudioNotifyServiceHelper StudioNotifyServiceHelper { get; }
|
2020-07-30 13:33:54 +00:00
|
|
|
|
2020-08-24 18:41:06 +00:00
|
|
|
public StudioNotifyServiceScope(TenantManager tenantManager, StudioNotifyServiceHelper studioNotifyServiceHelper)
|
|
|
|
{
|
|
|
|
TenantManager = tenantManager;
|
|
|
|
StudioNotifyServiceHelper = studioNotifyServiceHelper;
|
2020-07-30 13:33:54 +00:00
|
|
|
}
|
2020-08-31 08:18:07 +00:00
|
|
|
|
|
|
|
public void Deconstruct(out TenantManager tenantManager, out StudioNotifyServiceHelper studioNotifyServiceHelper)
|
|
|
|
{
|
|
|
|
tenantManager = TenantManager;
|
|
|
|
studioNotifyServiceHelper = StudioNotifyServiceHelper;
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|
2019-10-31 11:28:30 +00:00
|
|
|
|
2019-11-11 09:03:49 +00:00
|
|
|
public static class StudioNotifyServiceExtension
|
2019-10-31 11:28:30 +00:00
|
|
|
{
|
2020-10-27 15:34:22 +00:00
|
|
|
public static void Register(DIHelper services)
|
2019-10-31 11:28:30 +00:00
|
|
|
{
|
2020-10-28 20:02:03 +00:00
|
|
|
services.TryAdd<StudioNotifyServiceScope>();
|
2019-10-31 11:28:30 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-14 16:14:24 +00:00
|
|
|
}
|