mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-07 04:18:38 +00:00
commit
d64aa421fe
3 changed files with 38 additions and 1 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -8,4 +8,6 @@ riderModule.iml
|
|||
/.idea/.idea.ProjectLighthouse/.idea/dataSources.local.xml
|
||||
*.sln.DotSettings.user
|
||||
/ProjectLighthouse/r/*
|
||||
/ProjectLighthouse/logs/*
|
||||
/ProjectLighthouse/logs/*
|
||||
/ProjectLighthouse/ProjectLighthouse.csproj.user
|
||||
.vs/
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.Json;
|
||||
using System.Xml;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
|
@ -129,5 +130,25 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
if (this.database.ChangeTracker.HasChanges()) await this.database.SaveChangesAsync(); // save the user to the database if we changed anything
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
[HttpPost("update_my_pins")]
|
||||
public async Task<IActionResult> UpdateMyPins()
|
||||
{
|
||||
User user = await this.database.UserFromRequest(this.Request);
|
||||
if (user == null) return this.StatusCode(403, "");
|
||||
|
||||
string pinsString = await new System.IO.StreamReader(this.Request.Body).ReadToEndAsync();
|
||||
Pins pinJson = JsonSerializer.Deserialize<Pins>(pinsString);
|
||||
|
||||
// Sometimes the update gets called periodically as pin progress updates via playing,
|
||||
// may not affect equipped profile pins however, so check before setting it.
|
||||
string currentPins = user.Pins;
|
||||
string newPins = string.Join(",", pinJson.ProfilePins);
|
||||
if (!String.Equals(currentPins,newPins)) {
|
||||
user.Pins = newPins;
|
||||
await this.database.SaveChangesAsync();
|
||||
}
|
||||
return this.Ok("[{\"StatusCode\":200}]");
|
||||
}
|
||||
}
|
||||
}
|
14
ProjectLighthouse/Types/Profiles/Pins.cs
Normal file
14
ProjectLighthouse/Types/Profiles/Pins.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Text.Json.Serialization;
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Profiles
|
||||
{
|
||||
public class Pins
|
||||
{
|
||||
[JsonPropertyName("progress")]
|
||||
public long[] Progress { get; set; }
|
||||
[JsonPropertyName("awards")]
|
||||
public long[] Awards { get; set; }
|
||||
[JsonPropertyName("profile_pins")]
|
||||
public long[] ProfilePins { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue