Skip to content

Commit

Permalink
Mark all FirebaseLegacy code as obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Feb 3, 2024
1 parent 78a7f97 commit a2724f9
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy;
/// Implementation of <see cref=" AuthenticationHandler"/> for <see cref="FcmLegacyNotifier"/>.
/// </summary>
/// <param name="optionsAccessor">The options accessor for <see cref="FcmLegacyNotifierOptions"/>.</param>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
internal class FcmLegacyAuthenticationHandler(IOptionsSnapshot<FcmLegacyNotifierOptions> optionsAccessor) : AuthenticationHandler
{
private readonly FcmLegacyNotifierOptions options = optionsAccessor?.Value ?? throw new ArgumentNullException(nameof(optionsAccessor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy;
/// </summary>
/// <param name="httpClient">The <see cref="HttpClient"/> for making requests.</param>
/// <param name="optionsAccessor">The options accessor for <see cref="FcmLegacyNotifierOptions"/>.</param>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyNotifier(HttpClient httpClient, IOptionsSnapshot<FcmLegacyNotifierOptions> optionsAccessor) : AbstractHttpApiClient<FcmLegacyNotifierOptions>(httpClient, optionsAccessor)
{
private const string BaseUrl = "https://fcm.googleapis.com/fcm/send";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Microsoft.Extensions.Options;
using Tingle.Extensions.PushNotifications;

namespace Microsoft.Extensions.DependencyInjection;

[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
internal class FcmLegacyNotifierConfigureOptions : IValidateOptions<FcmLegacyNotifierOptions>
{
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Tingle.Extensions.Http;
using Tingle.Extensions.PushNotifications;
using Tingle.Extensions.PushNotifications.FcmLegacy;

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>Configuration options for <see cref="FcmLegacyNotifier"/>.</summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyNotifierOptions : AbstractHttpApiClientOptions
{
/// <summary>The authentication key for Firebase using the legacy HTTP API.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents a reason why an FCM request failed in the legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
[JsonConverter(typeof(JsonStringEnumConverter<FcmLegacyErrorCode>))]
public enum FcmLegacyErrorCode
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Abstractions for an FCM notification using legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public abstract class FcmLegacyNotification
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents an <see cref="FcmLegacyNotification"/> for Android in the legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyNotificationAndroid : FcmLegacyNotification
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents an <see cref="FcmLegacyNotification"/> for iOS.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyNotificationIos : FcmLegacyNotification
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents an <see cref="FcmLegacyNotification"/> for Web (i.e. Chrome).
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyNotificationWeb : FcmLegacyNotification
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents the priority of an FCM request in the legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
[JsonConverter(typeof(JsonStringEnumConverter<FcmLegacyPriority>))]
public enum FcmLegacyPriority
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents a request payload sent to Firebase Cloud Messaging (FCM) using the legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyRequest
{
/// <summary>
Expand Down Expand Up @@ -133,6 +134,7 @@ public class FcmLegacyRequest
/// Represents a request payload sent to Firebase Cloud Messaging (FCM) using the legacy HTTP API.
/// </summary>
/// <typeparam name="TNotification">The type for use with the <see cref="Notification"/> property.</typeparam>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyRequest<TNotification> : FcmLegacyRequest where TNotification : FcmLegacyNotification, new() // using the generic type solves a serialization issue with System.Text.Json
{
/// <summary>
Expand All @@ -149,14 +151,17 @@ public class FcmLegacyRequest
/// <summary>
/// Represents a request payload sent to Firebase Cloud Messaging (FCM) using the legacy HTTP API to Android.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyRequestAndroid : FcmLegacyRequest<FcmLegacyNotificationAndroid> { }

/// <summary>
/// Represents a request payload sent to Firebase Cloud Messaging (FCM) using the legacy HTTP API to iOS.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyRequestIos : FcmLegacyRequest<FcmLegacyNotificationIos> { }

/// <summary>
/// Represents a request payload sent to Firebase Cloud Messaging (FCM) using the legacy HTTP API to Web.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyRequestWeb : FcmLegacyRequest<FcmLegacyNotificationWeb> { }
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents a response payload received from Firebase Cloud Messaging (FCM) in the legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyResponse
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Tingle.Extensions.PushNotifications.FcmLegacy.Models;
/// <summary>
/// Represents the result of each sent message using the legacy HTTP API.
/// </summary>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public class FcmLegacyResult
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Tingle.Extensions.Http;
using Tingle.Extensions.PushNotifications;
using Tingle.Extensions.PushNotifications.Apple;
using Tingle.Extensions.PushNotifications.FcmLegacy;
using Tingle.Extensions.PushNotifications.Firebase;
Expand All @@ -14,6 +15,7 @@ public static class IServiceCollectionExtensions
/// <param name="services">The <see cref="IServiceCollection"/> to add to.</param>
/// <param name="configure">Action to configure <see cref="FcmLegacyNotifierOptions"/> instances.</param>
/// <returns>An <see cref="IHttpClientBuilder"/> that can be used to configure the client.</returns>
[Obsolete(MessageStrings.FirebaseLegacyObsoleteMessage)]
public static IHttpClientBuilder AddFcmLegacyNotifier(this IServiceCollection services, Action<FcmLegacyNotifierOptions>? configure = null)
{
// configure authentication
Expand Down
2 changes: 2 additions & 0 deletions src/Tingle.Extensions.PushNotifications/MessageStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ internal class MessageStrings
{
internal const string SerializationUnreferencedCodeMessage = "JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.";
internal const string SerializationRequiresDynamicCodeMessage = "JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.";

internal const string FirebaseLegacyObsoleteMessage = "FCM legacy APIs for HTTP and XMPP protocols are deprecated and will be removed in the future. Migrate to the HTTP v1 API (Tingle.Extensions.PushNotifications.Firebase) before June 2024 to ensure uninterrupted service. See https://firebase.google.com/docs/cloud-messaging/migrate-v1 for more details.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace Tingle.Extensions.PushNotifications;
[JsonSerializable(typeof(Apple.ApnsAuthenticationHandler.ApnsAuthHeader))]
[JsonSerializable(typeof(Apple.ApnsAuthenticationHandler.ApnsAuthPayload))]

#pragma warning disable CS0618 // Type or member is obsolete
[JsonSerializable(typeof(FcmLegacy.Models.FcmLegacyRequest))]
[JsonSerializable(typeof(FcmLegacy.Models.FcmLegacyRequestAndroid))]
[JsonSerializable(typeof(FcmLegacy.Models.FcmLegacyRequestIos))]
[JsonSerializable(typeof(FcmLegacy.Models.FcmLegacyRequestWeb))]
[JsonSerializable(typeof(FcmLegacy.Models.FcmLegacyResponse))]
#pragma warning restore CS0618 // Type or member is obsolete

[JsonSerializable(typeof(Firebase.Models.FirebaseRequest))]
[JsonSerializable(typeof(Firebase.Models.FirebaseResponse))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Tingle.Extensions.PushNotifications.FcmLegacy.Models;
using Xunit.Abstractions;

#pragma warning disable CS0618 // Type or member is obsolete

namespace Tingle.Extensions.PushNotifications.Tests;

public class FcmLegacyNotifierTests(ITestOutputHelper outputHelper)
Expand Down

0 comments on commit a2724f9

Please sign in to comment.