Push: api
This commit is contained in:
parent
393282ea92
commit
cac16ace79
@ -85,7 +85,6 @@ public class FirebaseDao
|
||||
|
||||
public FireBaseUser UpdateUser(Guid userId, int tenantId, string fbDeviceToken, bool isSubscribed, string application)
|
||||
{
|
||||
|
||||
var user = new FireBaseUser
|
||||
{
|
||||
UserId = userId,
|
||||
@ -98,9 +97,7 @@ public class FirebaseDao
|
||||
FirebaseDbContext.Update(user);
|
||||
FirebaseDbContext.SaveChanges();
|
||||
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public class FirebaseHelper
|
||||
_logger = logger;
|
||||
_firebaseDao = firebaseDao;
|
||||
|
||||
|
||||
var credentials = JsonConvert.SerializeObject(new FirebaseApiKey(_configuration)).Replace("\\\\", "\\");
|
||||
var defaultInstance = FirebaseApp.DefaultInstance;
|
||||
if (defaultInstance == null)
|
||||
@ -64,7 +65,6 @@ public class FirebaseHelper
|
||||
Credential = GoogleCredential.FromJson(credentials)
|
||||
});
|
||||
}
|
||||
_firebaseDao = firebaseDao;
|
||||
}
|
||||
|
||||
public void SendMessage(NotifyMessage msg)
|
||||
@ -114,4 +114,14 @@ public class FirebaseHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FireBaseUser RegisterUserDevice(Guid userId, int tenantId, string fbDeviceToken, bool isSubscribed, string application)
|
||||
{
|
||||
return _firebaseDao.RegisterUserDevice(userId, tenantId, fbDeviceToken, isSubscribed, application);
|
||||
}
|
||||
|
||||
public FireBaseUser UpdateUser(Guid userId, int tenantId, string fbDeviceToken, bool isSubscribed, string application)
|
||||
{
|
||||
return _firebaseDao.UpdateUser(userId, tenantId, fbDeviceToken, isSubscribed, application);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
using Constants = ASC.Core.Users.Constants;
|
||||
using FireBaseUser = ASC.Core.Common.EF.FireBaseUser;
|
||||
|
||||
namespace ASC.Web.Api.Controllers.Settings;
|
||||
public class SettingsController : BaseSettingsController
|
||||
@ -58,6 +59,7 @@ public class SettingsController : BaseSettingsController
|
||||
private readonly PasswordHasher _passwordHasher;
|
||||
private readonly ILogger _log;
|
||||
private readonly TelegramHelper _telegramHelper;
|
||||
private readonly FirebaseHelper _firebaseHelper;
|
||||
private readonly Constants _constants;
|
||||
private readonly DnsSettings _dnsSettings;
|
||||
|
||||
@ -90,6 +92,7 @@ public class SettingsController : BaseSettingsController
|
||||
ProviderManager providerManager,
|
||||
FirstTimeTenantSettings firstTimeTenantSettings,
|
||||
TelegramHelper telegramHelper,
|
||||
FirebaseHelper firebaseHelper,
|
||||
UrlShortener urlShortener,
|
||||
PasswordHasher passwordHasher,
|
||||
Constants constants,
|
||||
@ -124,6 +127,7 @@ public class SettingsController : BaseSettingsController
|
||||
_passwordHasher = passwordHasher;
|
||||
_urlShortener = urlShortener;
|
||||
_telegramHelper = telegramHelper;
|
||||
_firebaseHelper = firebaseHelper;
|
||||
_constants = constants;
|
||||
_dnsSettings = dnsSettings;
|
||||
}
|
||||
@ -688,6 +692,29 @@ public class SettingsController : BaseSettingsController
|
||||
public void TelegramDisconnect()
|
||||
{
|
||||
_telegramHelper.Disconnect(_authContext.CurrentAccount.ID, Tenant.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("push/docregisterdevice")]
|
||||
public FireBaseUser DocRegisterPusnNotificationDevice(FirebaseRequestsDto inDto)
|
||||
{
|
||||
return _firebaseHelper.RegisterUserDevice(_authContext.CurrentAccount.ID, Tenant.Id, inDto.FirebaseDeviceToken, inDto.IsSubscribed, PushConstants.PushDocAppName);
|
||||
}
|
||||
|
||||
[HttpPost("push/projregisterdevice")]
|
||||
public FireBaseUser ProjRegisterPusnNotificationDevice(FirebaseRequestsDto inDto)
|
||||
{
|
||||
return _firebaseHelper.RegisterUserDevice(_authContext.CurrentAccount.ID, Tenant.Id, inDto.FirebaseDeviceToken, inDto.IsSubscribed, PushConstants.PushDocAppName);
|
||||
}
|
||||
|
||||
[HttpPut("push/docsubscribe")]
|
||||
public FireBaseUser SubscribeDocumentsPushNotification(FirebaseRequestsDto inDto)
|
||||
{
|
||||
return _firebaseHelper.UpdateUser(_authContext.CurrentAccount.ID, Tenant.Id, inDto.FirebaseDeviceToken, inDto.IsSubscribed, PushConstants.PushDocAppName);
|
||||
}
|
||||
|
||||
[HttpPut("push/projsubscribe")]
|
||||
public FireBaseUser SubscribeProjectsPushNotification(FirebaseRequestsDto inDto)
|
||||
{
|
||||
return _firebaseHelper.UpdateUser(_authContext.CurrentAccount.ID, Tenant.Id, inDto.FirebaseDeviceToken, inDto.IsSubscribed, PushConstants.PushProjAppName);
|
||||
}
|
||||
}
|
33
web/ASC.Web.Api/ApiModels/RequestsDto/FirebaseRequestsDto.cs
Normal file
33
web/ASC.Web.Api/ApiModels/RequestsDto/FirebaseRequestsDto.cs
Normal file
@ -0,0 +1,33 @@
|
||||
// (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
|
||||
|
||||
namespace ASC.Web.Api.ApiModels.RequestsDto;
|
||||
|
||||
public class FirebaseRequestsDto
|
||||
{
|
||||
public string FirebaseDeviceToken { get; set; }
|
||||
public bool IsSubscribed { get; set; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user