43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using Microsoft.AspNetCore.SignalR;
|
|
using QuestShare.Common.API.Party;
|
|
using QuestShare.Server.Managers;
|
|
|
|
namespace QuestShare.Server.Hubs
|
|
{
|
|
public partial class ShareHub : Hub
|
|
{
|
|
[HubMethodName(nameof(PartyCheck))]
|
|
public async Task Server_PartyCheck(PartyCheck.Request request)
|
|
{
|
|
if (BanManager.IsBanned(Context))
|
|
{
|
|
Context.Abort();
|
|
return;
|
|
}
|
|
var error = Error.None;
|
|
if (request.CharacterId == 0) error = Error.InvalidCharacterId;
|
|
if (request.Token == "") error = Error.InvalidToken;
|
|
if (request.Version != Common.Constants.Version) error = Error.InvalidVersion;
|
|
var client = ClientManager.GetClient(Context.ConnectionId, request.Token);
|
|
if (client == null)
|
|
{
|
|
error = Error.Unauthorized;
|
|
if (BanManager.CheckBadRequests(Context, nameof(PartyCheck)))
|
|
{
|
|
error = Error.BannedTooManyBadRequests;
|
|
}
|
|
}
|
|
if (error != Error.None)
|
|
{
|
|
await Clients.Caller.SendAsync(nameof(PartyCheck), new PartyCheck.Response
|
|
{
|
|
Success = false,
|
|
Error = error,
|
|
});
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|