implement precense endpoint

This commit is contained in:
Alan Moon 2025-03-07 17:42:44 -08:00
parent 44aa98ef3a
commit ded2acc5ca
7 changed files with 1384 additions and 3 deletions

View 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);
}
}
}

View File

@ -177,7 +177,7 @@ public class ProfileController : Controller {
GameCurrency = currency.GameCurrency,
CashCurrency = currency.CashCurrency,
ActivityCount = 0,
BuddyCount = 0,
BuddyCount = viking.BuddiesMade.Count,
UserGradeData = new UserGrade { UserGradeID = 0 },
UserProfileTag = new UserProfileTag() {
CreateDate = new DateTime(DateTime.Now.Ticks),

File diff suppressed because it is too large Load Diff

View 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");
}
}
}

View File

@ -833,6 +833,9 @@ namespace sodoff.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool?>("Online")
.HasColumnType("INTEGER");
b.Property<int?>("SelectedDragonId")
.HasColumnType("INTEGER");

View File

@ -23,6 +23,8 @@ public class Viking {
public int? SelectedDragonId { get; set; }
public bool? Online { get; set; }
public virtual ICollection<Session> Sessions { get; set; } = null!;
public virtual User User { get; set; } = null!;
public virtual ICollection<Dragon> Dragons { get; set; } = null!;

View File

@ -158,7 +158,7 @@ public class BuddyService
DisplayName = XmlUtil.DeserializeXml<AvatarData>(buddy.BuddyViking.AvatarSerialized).DisplayName,
Status = buddy.BuddyStatus2,
CreateDate = buddy.CreatedAt,
Online = true, // hardcoded until mmo reports precense
Online = buddy.BuddyViking.Online ?? false,
OnMobile = false,
BestBuddy = buddy.IsBestFriend2
});
@ -169,7 +169,7 @@ public class BuddyService
DisplayName = XmlUtil.DeserializeXml<AvatarData>(buddy.Viking.AvatarSerialized).DisplayName,
Status = buddy.BuddyStatus1,
CreateDate = buddy.CreatedAt,
Online = true, // hardcoded until mmo reports precense
Online = buddy.Viking.Online ?? false,
OnMobile = false,
BestBuddy = buddy.IsBestFriend1
});