-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VCST-1334: Use Firebase Cloud Messaging (FCM) (#6)
- Loading branch information
1 parent
a75fe91
commit c6d2be9
Showing
48 changed files
with
1,835 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/VirtoCommerce.PushMessages.Core/Events/FcmTokenChangedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
using VirtoCommerce.Platform.Core.Events; | ||
using VirtoCommerce.PushMessages.Core.Models; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Events; | ||
|
||
public class FcmTokenChangedEvent : GenericChangedEntryEvent<FcmToken> | ||
{ | ||
public FcmTokenChangedEvent(IEnumerable<GenericChangedEntry<FcmToken>> changedEntries) | ||
: base(changedEntries) | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/VirtoCommerce.PushMessages.Core/Events/FcmTokenChangingEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
using VirtoCommerce.Platform.Core.Events; | ||
using VirtoCommerce.PushMessages.Core.Models; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Events; | ||
|
||
public class FcmTokenChangingEvent : GenericChangedEntryEvent<FcmToken> | ||
{ | ||
public FcmTokenChangingEvent(IEnumerable<GenericChangedEntry<FcmToken>> changedEntries) | ||
: base(changedEntries) | ||
{ | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/VirtoCommerce.PushMessages.Core/Extensions/EnumerableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Extensions; | ||
|
||
public static class EnumerableExtensions | ||
{ | ||
public static IList<T> ToIList<T>(this IEnumerable<T> enumerable) | ||
{ | ||
return enumerable.ToList(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/VirtoCommerce.PushMessages.Core/Extensions/PushMessageRecipientChangedEventExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using VirtoCommerce.Platform.Core.Common; | ||
using VirtoCommerce.PushMessages.Core.Events; | ||
using VirtoCommerce.PushMessages.Core.Models; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Extensions; | ||
|
||
public static class PushMessageRecipientChangedEventExtensions | ||
{ | ||
public static IDictionary<string, IList<PushMessageRecipient>> GetMessageIdsAndRecipients(this PushMessageRecipientChangedEvent @event) | ||
{ | ||
return @event.ChangedEntries | ||
.Where(x => x.EntryState == EntryState.Added) | ||
.GroupBy(x => x.NewEntry.MessageId) | ||
.ToDictionary(g => g.Key, g => g.Select(x => x.NewEntry).ToIList()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/VirtoCommerce.PushMessages.Core/Models/FcmReceiverOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace VirtoCommerce.PushMessages.Core.Models; | ||
|
||
public class FcmReceiverOptions | ||
{ | ||
public string ApiKey { get; set; } | ||
public string AuthDomain { get; set; } | ||
public string ProjectId { get; set; } | ||
public string StorageBucket { get; set; } | ||
public string MessagingSenderId { get; set; } | ||
public string AppId { get; set; } | ||
public string VapidKey { get; set; } | ||
} |
39 changes: 39 additions & 0 deletions
39
src/VirtoCommerce.PushMessages.Core/Models/FcmSenderOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Models; | ||
|
||
public class FcmSenderOptions | ||
{ | ||
[JsonProperty("type")] | ||
public string Type { get; set; } | ||
|
||
[JsonProperty("project_id")] | ||
public string ProjectId { get; set; } | ||
|
||
[JsonProperty("private_key_id")] | ||
public string PrivateKeyId { get; set; } | ||
|
||
[JsonProperty("private_key")] | ||
public string PrivateKey { get; set; } | ||
|
||
[JsonProperty("client_email")] | ||
public string ClientEmail { get; set; } | ||
|
||
[JsonProperty("client_id")] | ||
public string ClientId { get; set; } | ||
|
||
[JsonProperty("auth_uri")] | ||
public string AuthUri { get; set; } | ||
|
||
[JsonProperty("token_uri")] | ||
public string TokenUri { get; set; } | ||
|
||
[JsonProperty("auth_provider_x509_cert_url")] | ||
public string AuthProviderX509CertUrl { get; set; } | ||
|
||
[JsonProperty("client_x509_cert_url")] | ||
public string ClientX509CertUrl { get; set; } | ||
|
||
[JsonProperty("universe_domain")] | ||
public string UniverseDomain { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using VirtoCommerce.Platform.Core.Common; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Models; | ||
|
||
public class FcmToken : AuditableEntity, ICloneable | ||
{ | ||
public string Token { get; set; } | ||
|
||
public string UserId { get; set; } | ||
|
||
public object Clone() | ||
{ | ||
return MemberwiseClone(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/VirtoCommerce.PushMessages.Core/Models/FcmTokenSearchCriteria.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
using VirtoCommerce.Platform.Core.Common; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Models; | ||
|
||
public class FcmTokenSearchCriteria : SearchCriteriaBase | ||
{ | ||
public string Token { get; set; } | ||
|
||
public IList<string> UserIds { get; set; } | ||
} |
7 changes: 7 additions & 0 deletions
7
src/VirtoCommerce.PushMessages.Core/Models/FcmTokenSearchResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using VirtoCommerce.Platform.Core.Common; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Models; | ||
|
||
public class FcmTokenSearchResult : GenericSearchResult<FcmToken> | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
src/VirtoCommerce.PushMessages.Core/Models/PushMessageOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace VirtoCommerce.PushMessages.Core.Models; | ||
|
||
public class PushMessageOptions | ||
{ | ||
public bool UseFirebaseCloudMessaging { get; set; } | ||
public FcmSenderOptions FcmSenderOptions { get; set; } | ||
public FcmReceiverOptions FcmReceiverOptions { get; set; } | ||
} |
8 changes: 8 additions & 0 deletions
8
src/VirtoCommerce.PushMessages.Core/Services/IFcmTokenSearchService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using VirtoCommerce.Platform.Core.GenericCrud; | ||
using VirtoCommerce.PushMessages.Core.Models; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Services; | ||
|
||
public interface IFcmTokenSearchService : ISearchService<FcmTokenSearchCriteria, FcmTokenSearchResult, FcmToken> | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
src/VirtoCommerce.PushMessages.Core/Services/IFcmTokenService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using VirtoCommerce.Platform.Core.GenericCrud; | ||
using VirtoCommerce.PushMessages.Core.Models; | ||
|
||
namespace VirtoCommerce.PushMessages.Core.Services; | ||
|
||
public interface IFcmTokenService : ICrudService<FcmToken> | ||
{ | ||
} |
Oops, something went wrong.