Skip to content

Commit

Permalink
fix(templates): Fix small issues in Boilerplate #9384 (#9385)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi authored Dec 2, 2024
1 parent 90754c0 commit 816335a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/todo-sample.cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
cd src/Templates/Boilerplate && dotnet build -c Release
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0
dotnet new install Bit.Boilerplate.0.0.0.nupkg
cd ../../../ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --framework net8.0
cd ../../../ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net8.0
- name: Update core appsettings.json
uses: devops-actions/[email protected]
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
cd src\Templates\Boilerplate && dotnet build -c Release
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0
dotnet new install Bit.Boilerplate.0.0.0.nupkg
cd ..\..\..\ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --windows --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --captcha reCaptcha --framework net8.0
cd ..\..\..\ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --windows --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --captcha reCaptcha --signalR --framework net8.0
- name: Update core appsettings.json
uses: devops-actions/[email protected]
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
cd src/Templates/Boilerplate && dotnet build -c Release
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0
dotnet new install Bit.Boilerplate.0.0.0.nupkg
cd ../../../ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --framework net8.0
cd ../../../ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net8.0
- name: Extract Android signing key from env
uses: timheuer/[email protected]
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
cd src/Templates/Boilerplate && dotnet build -c Release
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0
dotnet new install Bit.Boilerplate.0.0.0.nupkg
cd ../../../ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --appInsights --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --framework net8.0
cd ../../../ && dotnet new bit-bp --name TodoSample --database PostgreSQL --sample Todo --appInsights --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net8.0
- name: Update core appsettings.json
uses: devops-actions/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,15 @@ response.IsSuccessStatusCode is false &&
|| exp is TaskCanceledException tcExp && tcExp.InnerException is TimeoutException
|| exp is HttpRequestException { StatusCode: HttpStatusCode.BadGateway or HttpStatusCode.GatewayTimeout or HttpStatusCode.ServiceUnavailable })
{
//#if (signalR != true)
serverCommunicationSuccess = false; // Let's treat the server communication as failed if an exception is caught here.
//#endif
throw new ServerConnectionException(localizer[nameof(AppStrings.ServerConnectionException)], exp);
}
//#if (signalR != true)
finally
{
if (isInternalRequest)
{
pubSubService.Publish(ClientPubSubMessages.IS_ONLINE_CHANGED, serverCommunicationSuccess);
}
}
//#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public static partial class MauiProgram
{
public static MauiApp CreateMauiApp()
{
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogException(e.ExceptionObject);
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogException(e.ExceptionObject, reportedBy: nameof(AppDomain.UnhandledException));
TaskScheduler.UnobservedTaskException += (_, e) =>
{
if (LogException(e.Exception))
if (LogException(e.Exception, nameof(TaskScheduler.UnobservedTaskException)))
{
e.SetObserved();
}
Expand Down Expand Up @@ -196,12 +196,15 @@ public override void DecidePolicy(WKWebView webView, WKNavigationAction navigati
}
#endif

private static bool LogException(object? error)
private static bool LogException(object? error, string reportedBy)
{
var errorMessage = error?.ToString() ?? "Unknown error";
if (IPlatformApplication.Current?.Services is IServiceProvider services && error is Exception exp)
{
services.GetRequiredService<IExceptionHandler>().Handle(exp);
services.GetRequiredService<IExceptionHandler>().Handle(exp, parameters: new()
{
{ nameof(reportedBy), reportedBy }
});
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ self.assetsInclude = [];
self.assetsExclude = [
/bit\.blazorui\.fluent\.css$/,
/bit\.blazorui\.fluent-dark\.css$/,
/bit\.blazorui\.fluent-light\.css$/
/bit\.blazorui\.fluent-light\.css$/,
// If a PDF viewer is needed in the PWA, remove these two lines:
/pdfjs-4\.7\.76\.js$/,
/pdfjs-4\.7\.76-worker\.js$/
];
self.externalAssets = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public partial class Program
[STAThread]
public static void Main(string[] args)
{
Application.ThreadException += (_, e) => LogException(e.Exception);
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogException(e.ExceptionObject);
TaskScheduler.UnobservedTaskException += (_, e) => { LogException(e.Exception); e.SetObserved(); };
Application.ThreadException += (_, e) => LogException(e.Exception, reportedBy: nameof(Application.ThreadException));
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogException(e.ExceptionObject, reportedBy: nameof(AppDomain.UnhandledException));
TaskScheduler.UnobservedTaskException += (_, e) => { LogException(e.Exception, reportedBy: nameof(TaskScheduler.UnobservedTaskException)); e.SetObserved(); };

ApplicationConfiguration.Initialize();

Expand Down Expand Up @@ -122,12 +122,15 @@ public static void Main(string[] args)
Application.Run(form);
}

private static void LogException(object? error)
private static void LogException(object? error, string reportedBy)
{
var errorMessage = error?.ToString() ?? "Unknown error";
if (Services is not null && error is Exception exp)
{
Services.GetRequiredService<IExceptionHandler>().Handle(exp);
Services.GetRequiredService<IExceptionHandler>().Handle(exp, parameters: new()
{
{ nameof(reportedBy), reportedBy }
});
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,15 @@ public async Task SendTwoFactorToken(SignInRequestDto request, CancellationToken
sendMessagesTasks.Add(phoneService.SendSms(message, user.PhoneNumber!, cancellationToken));
}

//#if (signalR == true)
if (firstStepAuthenticationMethod != "SignalR")
{
sendMessagesTasks.Add(appHubContext.Clients.User(user.Id.ToString()).SendAsync(SignalREvents.SHOW_MESSAGE, message, cancellationToken));
}
//#endif

//#if (notification == true)
if (firstStepAuthenticationMethod != "Push")
{
//#if (signalR == true)
sendMessagesTasks.Add(appHubContext.Clients.User(user.Id.ToString()).SendAsync(SignalREvents.SHOW_MESSAGE, message, cancellationToken));
//#endif
//#if (notification == true)
sendMessagesTasks.Add(pushNotificationService.RequestPush(message: message, userRelatedPush: true, customSubscriptionFilter: s => s.UserSession!.UserId == user.Id, cancellationToken: cancellationToken));
//#endif
}
//#endif

await Task.WhenAll(sendMessagesTasks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static partial class SignInManagerExtensions
/// 5. When the browser is redirected to a magic link created after a social sign-in, to automatically authenticate the user.
/// 6. When the user opts to sign in using a 6-digit code delivered via native push notification, web push or SignalR message (if configured).
///
/// It's important to clarify the authentication method (e.g., Social, SMS, Email, or Push Notification)
/// It's important to clarify the authentication method (e.g., Social, SMS, Email, or Push)
/// to avoid sending a second step to the same communication channel: For successful two-step authentication, the user must use a different method for the second step.
/// </summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ public async Task Subscribe([Required] PushNotificationSubscriptionDto dto, Canc

var userSessionId = httpContextAccessor.HttpContext!.User.IsAuthenticated() ? httpContextAccessor.HttpContext.User.GetSessionId() : (Guid?)null;

var subscription = await dbContext.PushNotificationSubscriptions.FindAsync([dto.DeviceId], cancellationToken);
await dbContext.PushNotificationSubscriptions
.Where(s => s.DeviceId == dto.DeviceId || s.UserSessionId == userSessionId /* pushManager's subscription has been renewed. */)
.ExecuteDeleteAsync(cancellationToken);

if (subscription is null)
var subscription = dbContext.PushNotificationSubscriptions.Add(new()
{
dbContext.PushNotificationSubscriptions.Add(subscription = new()
{
DeviceId = dto.DeviceId,
Platform = dto.Platform
});
}
DeviceId = dto.DeviceId,
Platform = dto.Platform
}).Entity;

dto.Patch(subscription);

Expand Down

0 comments on commit 816335a

Please sign in to comment.