mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
bugfixes for mmo info from API server
- fix database exception in GetAllActivePetsByuserId - fix exception when GetUserProfileByUserID call with invalid userId
This commit is contained in:
parent
391be35a7a
commit
d9e3315d41
@ -376,9 +376,13 @@ public class ContentController : Controller {
|
|||||||
[Route("V2/ContentWebService.asmx/GetAllActivePetsByuserId")]
|
[Route("V2/ContentWebService.asmx/GetAllActivePetsByuserId")]
|
||||||
public RaisedPetData[]? GetAllActivePetsByuserId([FromForm] string userId, [FromForm] bool active) {
|
public RaisedPetData[]? GetAllActivePetsByuserId([FromForm] string userId, [FromForm] bool active) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
||||||
|
if (viking is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
RaisedPetData[] dragons = ctx.Dragons
|
RaisedPetData[] dragons = ctx.Dragons
|
||||||
.Where(d => d.VikingId == userId && d.RaisedPetData != null)
|
.Where(d => d.VikingId == userId && d.RaisedPetData != null)
|
||||||
.Select(GetRaisedPetDataFromDragon)
|
.Select(d => GetRaisedPetDataFromDragon(d, viking.SelectedDragonId))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
if (dragons.Length == 0) {
|
if (dragons.Length == 0) {
|
||||||
@ -394,7 +398,7 @@ public class ContentController : Controller {
|
|||||||
public RaisedPetData[]? GetUnselectedPetByTypes(Viking viking, [FromForm] string petTypeIDs, [FromForm] bool active) {
|
public RaisedPetData[]? GetUnselectedPetByTypes(Viking viking, [FromForm] string petTypeIDs, [FromForm] bool active) {
|
||||||
RaisedPetData[] dragons = viking.Dragons
|
RaisedPetData[] dragons = viking.Dragons
|
||||||
.Where(d => d.RaisedPetData is not null)
|
.Where(d => d.RaisedPetData is not null)
|
||||||
.Select(GetRaisedPetDataFromDragon)
|
.Select(d => GetRaisedPetDataFromDragon(d, viking.SelectedDragonId))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
if (dragons.Length == 0) {
|
if (dragons.Length == 0) {
|
||||||
@ -703,6 +707,7 @@ public class ContentController : Controller {
|
|||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetUserRoomList")]
|
[Route("ContentWebService.asmx/GetUserRoomList")]
|
||||||
public IActionResult GetUserRoomList([FromForm] string request) {
|
public IActionResult GetUserRoomList([FromForm] string request) {
|
||||||
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
// TODO: Categories are not supported
|
// TODO: Categories are not supported
|
||||||
UserRoomGetRequest userRoomRequest = XmlUtil.DeserializeXml<UserRoomGetRequest>(request);
|
UserRoomGetRequest userRoomRequest = XmlUtil.DeserializeXml<UserRoomGetRequest>(request);
|
||||||
ICollection<Room>? rooms = ctx.Vikings.FirstOrDefault(x => x.Id == userRoomRequest.UserID.ToString())?.Rooms;
|
ICollection<Room>? rooms = ctx.Vikings.FirstOrDefault(x => x.Id == userRoomRequest.UserID.ToString())?.Rooms;
|
||||||
@ -1150,11 +1155,13 @@ public class ContentController : Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private RaisedPetData GetRaisedPetDataFromDragon (Dragon dragon) {
|
private static RaisedPetData GetRaisedPetDataFromDragon (Dragon dragon, int? selectedDragonId = null) {
|
||||||
|
if (selectedDragonId is null)
|
||||||
|
selectedDragonId = dragon.Viking.SelectedDragonId;
|
||||||
RaisedPetData data = XmlUtil.DeserializeXml<RaisedPetData>(dragon.RaisedPetData);
|
RaisedPetData data = XmlUtil.DeserializeXml<RaisedPetData>(dragon.RaisedPetData);
|
||||||
data.RaisedPetID = dragon.Id;
|
data.RaisedPetID = dragon.Id;
|
||||||
data.EntityID = Guid.Parse(dragon.EntityId);
|
data.EntityID = Guid.Parse(dragon.EntityId);
|
||||||
data.IsSelected = (dragon.Viking.SelectedDragonId == dragon.Id);
|
data.IsSelected = (selectedDragonId == dragon.Id);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,14 +19,13 @@ public class ProfileController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ProfileWebService.asmx/GetUserProfileByUserID")]
|
[Route("ProfileWebService.asmx/GetUserProfileByUserID")]
|
||||||
public IActionResult GetUserProfileByUserID([FromForm] string apiToken, [FromForm] string userId) {
|
public IActionResult GetUserProfileByUserID([FromForm] string userId) {
|
||||||
Session session = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken);
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
if (session?.User is null && session?.Viking is null) {
|
|
||||||
// TODO: what response for not logged in?
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
||||||
|
if (viking is null)
|
||||||
|
return Conflict("Viking not found");
|
||||||
|
|
||||||
return Ok(GetProfileDataFromViking(viking));
|
return Ok(GetProfileDataFromViking(viking));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user