DocSpace-client/web/ASC.Web.Core/Notify/StudioNotifySource.cs

252 lines
10 KiB
C#
Raw Normal View History

2022-03-15 18:00:53 +00:00
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL 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 details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
2022-03-17 15:13:38 +00:00
namespace ASC.Web.Studio.Core.Notify;
[Scope]
public class StudioNotifySource : NotifySource
{
2022-03-17 15:13:38 +00:00
public StudioNotifySource(UserManager userManager, IRecipientProvider recipientsProvider, SubscriptionManager subscriptionManager)
: base("asc.web.studio", userManager, recipientsProvider, subscriptionManager)
{
2022-03-17 15:13:38 +00:00
}
protected override IActionProvider CreateActionProvider()
{
return new ConstActionProvider(
Actions.SelfProfileUpdated,
Actions.JoinUsers,
Actions.SendWhatsNew,
Actions.UserHasJoin,
Actions.BackupCreated,
Actions.RestoreStarted,
Actions.RestoreCompletedV115,
Actions.PortalDeactivate,
Actions.PortalDelete,
Actions.PortalDeleteSuccessV1,
2022-03-17 15:13:38 +00:00
Actions.DnsChange,
Actions.ConfirmOwnerChange,
Actions.EmailChangeV115,
2022-06-14 08:11:41 +00:00
Actions.PasswordChangeV115,
2022-03-17 15:13:38 +00:00
Actions.ActivateEmail,
Actions.ProfileDelete,
Actions.ProfileHasDeletedItself,
Actions.ReassignsCompleted,
Actions.ReassignsFailed,
Actions.RemoveUserDataCompleted,
Actions.RemoveUserDataCompletedCustomMode,
Actions.RemoveUserDataFailed,
Actions.PhoneChange,
Actions.MigrationPortalStart,
Actions.MigrationPortalSuccessV115,
Actions.MigrationPortalError,
Actions.MigrationPortalServerFailure,
Actions.UserMessageToAdmin,
Actions.SaasGuestActivationV115,
Actions.EnterpriseGuestActivationV10,
Actions.EnterpriseWhitelabelGuestActivationV10,
Actions.OpensourceGuestActivationV11,
Actions.SaasGuestWelcomeV115,
Actions.EnterpriseGuestWelcomeV10,
Actions.EnterpriseWhitelabelGuestWelcomeV10,
Actions.OpensourceGuestWelcomeV11,
Actions.EnterpriseAdminInviteTeammatesV10,
Actions.EnterpriseAdminWithoutActivityV10,
Actions.EnterpriseAdminUserAppsTipsV10,
Actions.EnterpriseAdminTrialWarningBefore7V10,
Actions.EnterpriseAdminTrialWarningV10,
Actions.EnterpriseAdminPaymentWarningBefore7V10,
Actions.EnterpriseWhitelabelAdminPaymentWarningBefore7V10,
Actions.EnterpriseAdminPaymentWarningV10,
Actions.EnterpriseWhitelabelAdminPaymentWarningV10,
2022-10-13 13:22:08 +00:00
Actions.SaasAdminModulesV1,
2022-03-17 15:13:38 +00:00
Actions.PersonalActivate,
Actions.PersonalAfterRegistration1,
Actions.PersonalAfterRegistration7,
Actions.PersonalAfterRegistration14,
Actions.PersonalAfterRegistration21,
Actions.PersonalAfterRegistration14V1,
2022-03-17 15:13:38 +00:00
Actions.PersonalConfirmation,
2022-06-14 08:11:41 +00:00
Actions.PersonalPasswordChangeV115,
2022-03-17 15:13:38 +00:00
Actions.PersonalEmailChangeV115,
Actions.PersonalProfileDelete,
Actions.PersonalAlreadyExist,
Actions.MailboxCreated,
Actions.MailboxWithoutSettingsCreated,
Actions.MailboxCreated,
Actions.MailboxWithoutSettingsCreated,
Actions.PersonalCustomModeAfterRegistration1,
Actions.PersonalCustomModeConfirmation,
2022-06-14 08:11:41 +00:00
Actions.PersonalCustomModePasswordChangeV115,
2022-03-17 15:13:38 +00:00
Actions.PersonalCustomModeEmailChangeV115,
Actions.PersonalCustomModeProfileDelete,
Actions.PersonalCustomModeAlreadyExist,
Actions.SaasCustomModeRegData,
Actions.StorageEncryptionStart,
Actions.StorageEncryptionSuccess,
Actions.StorageEncryptionError,
Actions.StorageDecryptionStart,
Actions.StorageDecryptionSuccess,
Actions.StorageDecryptionError,
Actions.SaasAdminActivationV1,
Actions.EnterpriseAdminActivationV1,
Actions.EnterpriseWhitelabelAdminActivationV1,
Actions.OpensourceAdminActivationV1,
Actions.SaasAdminWelcomeV1,
Actions.EnterpriseAdminWelcomeV1,
Actions.EnterpriseWhitelabelAdminWelcomeV1,
Actions.OpensourceAdminWelcomeV1,
Actions.SaasAdminUserDocsTipsV1,
Actions.OpensourceAdminDocsTipsV1,
Actions.OpensourceUserDocsTipsV1,
Actions.EnterpriseAdminUserDocsTipsV1,
Actions.SaasAdminTrialWarningAfterHalfYearV1,
Actions.SaasUserWelcomeV1,
Actions.EnterpriseUserWelcomeV1,
Actions.EnterpriseWhitelabelUserWelcomeV1,
Actions.EnterpriseWhitelabelUserWelcomeCustomMode,
Actions.OpensourceUserWelcomeV1,
Actions.SaasUserActivationV1,
Actions.EnterpriseUserActivationV1,
Actions.EnterpriseWhitelabelUserActivationV1,
Actions.OpensourceUserActivationV1
2022-03-17 15:13:38 +00:00
);
}
protected override IPatternProvider CreatePatternsProvider()
{
return new XmlPatternProvider2(WebPatternResource.webstudio_patterns);
}
protected override ISubscriptionProvider CreateSubscriptionProvider()
{
return new AdminNotifySubscriptionProvider(base.CreateSubscriptionProvider());
}
private class AdminNotifySubscriptionProvider : ISubscriptionProvider
{
2022-03-17 16:57:02 +00:00
private readonly ISubscriptionProvider _provider;
2022-03-17 15:13:38 +00:00
public AdminNotifySubscriptionProvider(ISubscriptionProvider provider)
{
2022-03-17 16:57:02 +00:00
this._provider = provider;
}
2022-03-17 15:13:38 +00:00
public object GetSubscriptionRecord(INotifyAction action, IRecipient recipient, string objectID)
{
2022-03-17 16:57:02 +00:00
return _provider.GetSubscriptionRecord(GetAdminAction(action), recipient, objectID);
}
2022-03-17 15:13:38 +00:00
public string[] GetSubscriptions(INotifyAction action, IRecipient recipient, bool checkSubscription = true)
{
2022-03-17 16:57:02 +00:00
return _provider.GetSubscriptions(GetAdminAction(action), recipient, checkSubscription);
}
2022-03-17 15:13:38 +00:00
public void Subscribe(INotifyAction action, string objectID, IRecipient recipient)
{
2022-03-17 16:57:02 +00:00
_provider.Subscribe(GetAdminAction(action), objectID, recipient);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public void UnSubscribe(INotifyAction action, IRecipient recipient)
{
2022-03-17 16:57:02 +00:00
_provider.UnSubscribe(GetAdminAction(action), recipient);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public void UnSubscribe(INotifyAction action)
{
2022-03-17 16:57:02 +00:00
_provider.UnSubscribe(GetAdminAction(action));
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public void UnSubscribe(INotifyAction action, string objectID)
{
2022-03-17 16:57:02 +00:00
_provider.UnSubscribe(GetAdminAction(action), objectID);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public void UnSubscribe(INotifyAction action, string objectID, IRecipient recipient)
{
2022-03-17 16:57:02 +00:00
_provider.UnSubscribe(GetAdminAction(action), objectID, recipient);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public void UpdateSubscriptionMethod(INotifyAction action, IRecipient recipient, params string[] senderNames)
{
2022-03-17 16:57:02 +00:00
_provider.UpdateSubscriptionMethod(GetAdminAction(action), recipient, senderNames);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public IRecipient[] GetRecipients(INotifyAction action, string objectID)
{
2022-03-17 16:57:02 +00:00
return _provider.GetRecipients(GetAdminAction(action), objectID);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public string[] GetSubscriptionMethod(INotifyAction action, IRecipient recipient)
{
2022-03-17 16:57:02 +00:00
return _provider.GetSubscriptionMethod(GetAdminAction(action), recipient);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
public bool IsUnsubscribe(IDirectRecipient recipient, INotifyAction action, string objectID)
{
2022-03-17 16:57:02 +00:00
return _provider.IsUnsubscribe(recipient, action, objectID);
2022-03-17 15:13:38 +00:00
}
2022-03-17 15:13:38 +00:00
private INotifyAction GetAdminAction(INotifyAction action)
{
if (Actions.SelfProfileUpdated.ID == action.ID ||
Actions.UserHasJoin.ID == action.ID ||
2022-07-18 09:24:12 +00:00
Actions.UserMessageToAdmin.ID == action.ID
2022-03-17 15:13:38 +00:00
)
{
2022-03-17 15:13:38 +00:00
return Actions.AdminNotify;
}
2022-03-17 15:13:38 +00:00
else
{
2022-03-17 15:13:38 +00:00
return action;
}
}
}
}