add documentation how to install server on ubuntu 20.04 and add server version stuff

This commit is contained in:
Stanley Dimant
2022-07-03 15:33:34 +02:00
parent 15b220dc8b
commit d08e5f9c04
6 changed files with 111 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Security.Claims;
using System.Threading.Tasks;
using MareSynchronos.API;
@@ -10,11 +11,12 @@ namespace MareSynchronosServer.Hubs
{
public class ConnectionHub : BaseHub<ConnectionHub>
{
private const int ServerVersion = 1;
public ConnectionHub(MareDbContext mareDbContext, ILogger<ConnectionHub> logger) : base(mareDbContext, logger)
{
}
public async Task<LoggedInUserDto> Heartbeat()
public async Task<ConnectionDto> Heartbeat()
{
var userId = Context.User!.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;
@@ -23,15 +25,16 @@ namespace MareSynchronosServer.Hubs
{
Logger.LogInformation("Connection from " + userId);
var user = (await DbContext.Users.SingleAsync(u => u.UID == userId));
return new LoggedInUserDto
return new ConnectionDto
{
ServerVersion = ServerVersion,
UID = userId,
IsModerator = user.IsModerator,
IsAdmin = user.IsAdmin
};
}
return new LoggedInUserDto();
return new ConnectionDto();
}
}
}