mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-09-21 16:59:05 +00:00
Add support for setting profile pins
This commit is contained in:
parent
d1f0166973
commit
1c6f4f6d0f
2 changed files with 34 additions and 0 deletions
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||||
|
@ -129,5 +130,26 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
if (this.database.ChangeTracker.HasChanges()) await this.database.SaveChangesAsync(); // save the user to the database if we changed anything
|
if (this.database.ChangeTracker.HasChanges()) await this.database.SaveChangesAsync(); // save the user to the database if we changed anything
|
||||||
return this.Ok();
|
return this.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Profile only right now
|
||||||
|
[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 pinsText = await new System.IO.StreamReader(this.Request.Body).ReadToEndAsync();
|
||||||
|
Pins pinData = JsonSerializer.Deserialize<Pins>(pinsText);
|
||||||
|
|
||||||
|
// 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(",", pinData.profile_pins);
|
||||||
|
if (!String.Equals(currentPins,newPins)) {
|
||||||
|
user.Pins = newPins;
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
return this.Ok("[{\"StatusCode\":200}]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
12
ProjectLighthouse/Types/Profiles/Pins.cs
Normal file
12
ProjectLighthouse/Types/Profiles/Pins.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Types.Profiles
|
||||||
|
{
|
||||||
|
public class Pins
|
||||||
|
{
|
||||||
|
public long[] progress { get; set; }
|
||||||
|
public long[] awards { get; set; }
|
||||||
|
public long[] profile_pins { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue