forked from SoDOff-Project/sodoff
implement precense endpoint
This commit is contained in:
parent
44aa98ef3a
commit
ded2acc5ca
25
src/Controllers/Common/PrecenseController.cs
Normal file
25
src/Controllers/Common/PrecenseController.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using sodoff.Attributes;
|
||||||
|
using sodoff.Model;
|
||||||
|
|
||||||
|
namespace sodoff.Controllers.Common
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
public class PrecenseController : Controller
|
||||||
|
{
|
||||||
|
private readonly DBContext ctx;
|
||||||
|
public PrecenseController(DBContext ctx) => this.ctx = ctx;
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Route("Precense/SetVikingOnline")]
|
||||||
|
[VikingSession]
|
||||||
|
public IActionResult SetVikingOnline(Viking viking, [FromForm] bool online)
|
||||||
|
{
|
||||||
|
viking.Online = online;
|
||||||
|
ctx.SaveChanges();
|
||||||
|
return Ok(viking.Online);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -177,7 +177,7 @@ public class ProfileController : Controller {
|
|||||||
GameCurrency = currency.GameCurrency,
|
GameCurrency = currency.GameCurrency,
|
||||||
CashCurrency = currency.CashCurrency,
|
CashCurrency = currency.CashCurrency,
|
||||||
ActivityCount = 0,
|
ActivityCount = 0,
|
||||||
BuddyCount = 0,
|
BuddyCount = viking.BuddiesMade.Count,
|
||||||
UserGradeData = new UserGrade { UserGradeID = 0 },
|
UserGradeData = new UserGrade { UserGradeID = 0 },
|
||||||
UserProfileTag = new UserProfileTag() {
|
UserProfileTag = new UserProfileTag() {
|
||||||
CreateDate = new DateTime(DateTime.Now.Ticks),
|
CreateDate = new DateTime(DateTime.Now.Ticks),
|
||||||
|
1323
src/Migrations/20250308013623_Viking_Online.Designer.cs
generated
Normal file
1323
src/Migrations/20250308013623_Viking_Online.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
28
src/Migrations/20250308013623_Viking_Online.cs
Normal file
28
src/Migrations/20250308013623_Viking_Online.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace sodoff.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Viking_Online : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "Online",
|
||||||
|
table: "Vikings",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Online",
|
||||||
|
table: "Vikings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -833,6 +833,9 @@ namespace sodoff.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool?>("Online")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<int?>("SelectedDragonId")
|
b.Property<int?>("SelectedDragonId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ public class Viking {
|
|||||||
|
|
||||||
public int? SelectedDragonId { get; set; }
|
public int? SelectedDragonId { get; set; }
|
||||||
|
|
||||||
|
public bool? Online { get; set; }
|
||||||
|
|
||||||
public virtual ICollection<Session> Sessions { get; set; } = null!;
|
public virtual ICollection<Session> Sessions { get; set; } = null!;
|
||||||
public virtual User User { get; set; } = null!;
|
public virtual User User { get; set; } = null!;
|
||||||
public virtual ICollection<Dragon> Dragons { get; set; } = null!;
|
public virtual ICollection<Dragon> Dragons { get; set; } = null!;
|
||||||
|
@ -158,7 +158,7 @@ public class BuddyService
|
|||||||
DisplayName = XmlUtil.DeserializeXml<AvatarData>(buddy.BuddyViking.AvatarSerialized).DisplayName,
|
DisplayName = XmlUtil.DeserializeXml<AvatarData>(buddy.BuddyViking.AvatarSerialized).DisplayName,
|
||||||
Status = buddy.BuddyStatus2,
|
Status = buddy.BuddyStatus2,
|
||||||
CreateDate = buddy.CreatedAt,
|
CreateDate = buddy.CreatedAt,
|
||||||
Online = true, // hardcoded until mmo reports precense
|
Online = buddy.BuddyViking.Online ?? false,
|
||||||
OnMobile = false,
|
OnMobile = false,
|
||||||
BestBuddy = buddy.IsBestFriend2
|
BestBuddy = buddy.IsBestFriend2
|
||||||
});
|
});
|
||||||
@ -169,7 +169,7 @@ public class BuddyService
|
|||||||
DisplayName = XmlUtil.DeserializeXml<AvatarData>(buddy.Viking.AvatarSerialized).DisplayName,
|
DisplayName = XmlUtil.DeserializeXml<AvatarData>(buddy.Viking.AvatarSerialized).DisplayName,
|
||||||
Status = buddy.BuddyStatus1,
|
Status = buddy.BuddyStatus1,
|
||||||
CreateDate = buddy.CreatedAt,
|
CreateDate = buddy.CreatedAt,
|
||||||
Online = true, // hardcoded until mmo reports precense
|
Online = buddy.Viking.Online ?? false,
|
||||||
OnMobile = false,
|
OnMobile = false,
|
||||||
BestBuddy = buddy.IsBestFriend1
|
BestBuddy = buddy.IsBestFriend1
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user