Skip to content

Commit

Permalink
Merge branch 'main' into translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Slendy authored Jan 11, 2025
2 parents 12b31ca + 4f9dc2a commit 407afce
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Start MySQL
if: ${{ matrix.os.database }}
uses: shogo82148/actions-setup-mysql@v1.14.1
uses: shogo82148/actions-setup-mysql@v1.40.0
with:
mysql-version: '8.0'
root-password: ${{ env.DB_PASSWORD }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2024.1
uses: JetBrains/qodana-action@v2024.3
with:
pr-mode: false
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_1488465344 }}
QODANA_ENDPOINT: 'https://qodana.cloud'
- uses: github/codeql-action/upload-sarif@v2
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.StorableLists.Stores;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Logging;
Expand Down Expand Up @@ -159,7 +160,7 @@ public async Task<IActionResult> SubmitScore(string slotType, int id, int childI

await this.database.SaveChangesAsync();

return this.Ok(await this.GetScores(new LeaderboardOptions
ScoreboardResponse scores = await this.GetScores(new LeaderboardOptions
{
RootName = "scoreboardSegment",
PageSize = 5,
Expand All @@ -169,7 +170,17 @@ public async Task<IActionResult> SubmitScore(string slotType, int id, int childI
ScoreType = score.Type,
TargetUser = token.UserId,
TargetPlayerIds = null,
}));
});

if (score.Type == 1 && scores.YourRank == 1 && scores.Total > 1)

Check notice on line 175 in ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Invert 'if' statement to reduce nesting

Invert 'if' statement to reduce nesting

Check notice on line 175 in ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Merge null/pattern checks into complex pattern

Merge into pattern
{
GameScore? second = scores.Scores[1];
UserEntity? user = await this.database.UserFromGameToken(token);

await this.database.SendNotification(second.UserId, $"{user?.InfoXml} beat your highscore (<em>{second.Points}</em>) on {slot.InfoXml} with a score of <em>{score.Points}</em>.", true);

Check warning on line 180 in ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant argument with default value

The parameter 'prefix' has the same default value
}

return this.Ok(scores);
}

[HttpGet("scoreboard/{slotType}/{id:int}")]
Expand Down
23 changes: 14 additions & 9 deletions ProjectLighthouse/Database/DatabaseContext.Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public partial class DatabaseContext
/// </summary>
/// <param name="userId">The user ID of the target user.</param>
/// <param name="text">The message to send.</param>
/// <param name="prefix">Prepend server name/timestamp.</param>
/// <param name="type">The <see cref="NotificationType"/> for the notification. Defaults to <c>ModerationNotification</c>.</param>
public async Task SendNotification
(int userId, string text, NotificationType type = NotificationType.ModerationNotification)
(int userId, string text, bool prefix = true, NotificationType type = NotificationType.ModerationNotification)
{
if (!await this.Users.AnyAsync(u => u.UserId == userId))
{
Expand All @@ -31,15 +32,19 @@ public async Task SendNotification

StringBuilder builder = new(text);

// Prepend server name to notification text if enabled
if (ServerConfiguration.Instance.NotificationConfiguration.ShowServerNameInText)
if (prefix)
{
builder.Insert(0, $"[{ServerConfiguration.Instance.Customization.ServerName}] ");
}
// Prepend timestamp to notification text if enabled
if (ServerConfiguration.Instance.NotificationConfiguration.ShowTimestampInText)
{
builder.Insert(0, $"[{DateTime.Now:g}] ");
// Prepend server name to notification text if enabled
if (ServerConfiguration.Instance.NotificationConfiguration.ShowServerNameInText)
{
builder.Insert(0, $"[{ServerConfiguration.Instance.Customization.ServerName}] ");
}

// Prepend timestamp to notification text if enabled
if (ServerConfiguration.Instance.NotificationConfiguration.ShowTimestampInText)
{
builder.Insert(0, $"[{DateTime.Now:g}] ");
}
}

NotificationEntity notification = new()
Expand Down
7 changes: 7 additions & 0 deletions ProjectLighthouse/Types/Entities/Level/SlotEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public class SlotEntity

public string IconHash { get; set; } = "";

Check warning on line 30 in ProjectLighthouse/Types/Entities/Level/SlotEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

/// <summary>
/// Markup that displays the level name next to its badge.
/// This can be used everywhere markup works ingame, e.g. news or notifications
/// </summary>
[NotMapped]
public string InfoXml => $"<slot type=\"{this.Type}\" id=\"{this.SlotId}\" icon=\"{this.IconHash}\">{this.Name}</slot>";

public bool IsAdventurePlanet { get; set; }

public string RootLevel { get; set; } = "";

Check warning on line 41 in ProjectLighthouse/Types/Entities/Level/SlotEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length
Expand Down
7 changes: 7 additions & 0 deletions ProjectLighthouse/Types/Entities/Profile/UserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public class UserEntity

public string IconHash { get; set; }

Check warning on line 29 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

/// <summary>
/// Markup that displays the username next to a polaroid with the user's icon.
/// This can be used everywhere markup works ingame, e.g. news or notifications
/// </summary>
[NotMapped]
public string InfoXml => $"<player icon=\"{this.IconHash}\">{this.Username}</player>";

/// <summary>
/// A user-customizable biography shown on the profile card
/// </summary>
Expand Down

0 comments on commit 407afce

Please sign in to comment.