Track rule reading in database, don't show popup locally (#7278)

This commit is contained in:
DrSmugleaf
2022-03-26 20:16:57 +01:00
committed by GitHub
parent 19d8824951
commit ca0fb3c6a2
13 changed files with 2302 additions and 53 deletions

View File

@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Net;
@@ -10,13 +8,9 @@ using Content.Server.Administration.Logs;
using Content.Shared.Administration.Logs;
using Content.Shared.CharacterAppearance;
using Content.Shared.Preferences;
using Content.Shared.Species;
using Microsoft.EntityFrameworkCore;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Server.Database
@@ -774,6 +768,30 @@ namespace Content.Server.Database
await db.DbContext.SaveChangesAsync();
}
public async Task<DateTime?> GetLastReadRules(NetUserId player)
{
await using var db = await GetDb();
return await db.DbContext.Player
.Where(dbPlayer => dbPlayer.UserId == player)
.Select(dbPlayer => dbPlayer.LastReadRules)
.SingleOrDefaultAsync();
}
public async Task SetLastReadRules(NetUserId player, DateTime date)
{
await using var db = await GetDb();
var dbPlayer = await db.DbContext.Player.Where(dbPlayer => dbPlayer.UserId == player).SingleOrDefaultAsync();
if (dbPlayer == null)
{
return;
}
dbPlayer.LastReadRules = date;
await db.DbContext.SaveChangesAsync();
}
#endregion
#region Uploaded Resources Logs