feat(apiv2): delete endpoints
This commit is contained in:
parent
c164fad2ac
commit
0aefafb62d
@ -66,15 +66,20 @@ namespace PluralKit.API
|
||||
};
|
||||
}
|
||||
|
||||
[HttpDelete("groups/{group_id}")]
|
||||
public async Task<IActionResult> GroupDelete(string group_id)
|
||||
[HttpDelete("groups/{groupRef}")]
|
||||
public async Task<IActionResult> GroupDelete(string groupRef)
|
||||
{
|
||||
return new ObjectResult("Unimplemented")
|
||||
{
|
||||
StatusCode = 501
|
||||
};
|
||||
var group = await ResolveGroup(groupRef);
|
||||
if (group == null)
|
||||
throw APIErrors.GroupNotFound;
|
||||
|
||||
var system = await ResolveSystem("@me");
|
||||
if (system.Id != group.System)
|
||||
throw APIErrors.NotOwnGroupError;
|
||||
|
||||
await _repo.DeleteGroup(group.Id);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -67,15 +67,20 @@ namespace PluralKit.API
|
||||
};
|
||||
}
|
||||
|
||||
[HttpDelete("members/{member}")]
|
||||
public async Task<IActionResult> MemberDelete(string member)
|
||||
[HttpDelete("members/{memberRef}")]
|
||||
public async Task<IActionResult> MemberDelete(string memberRef)
|
||||
{
|
||||
return new ObjectResult("Unimplemented")
|
||||
{
|
||||
StatusCode = 501
|
||||
};
|
||||
var member = await ResolveMember(memberRef);
|
||||
if (member == null)
|
||||
throw APIErrors.MemberNotFound;
|
||||
|
||||
var system = await ResolveSystem("@me");
|
||||
if (system.Id != member.System)
|
||||
throw APIErrors.NotOwnMemberError;
|
||||
|
||||
await _repo.DeleteMember(member.Id);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -131,13 +131,20 @@ namespace PluralKit.API
|
||||
};
|
||||
}
|
||||
|
||||
[HttpDelete("systems/{system}/switches/{switch_id}")]
|
||||
public async Task<IActionResult> SwitchDelete(string system, string switch_id)
|
||||
[HttpDelete("systems/@me/switches/{switchRef}")]
|
||||
public async Task<IActionResult> SwitchDelete(string switchRef)
|
||||
{
|
||||
return new ObjectResult("Unimplemented")
|
||||
{
|
||||
StatusCode = 501
|
||||
};
|
||||
if (!Guid.TryParse(switchRef, out var switchId))
|
||||
throw APIErrors.SwitchNotFound;
|
||||
|
||||
var system = await ResolveSystem("@me");
|
||||
var sw = await _repo.GetSwitchByUuid(switchId);
|
||||
if (sw == null || system.Id != sw.System)
|
||||
throw APIErrors.SwitchNotFound;
|
||||
|
||||
await _repo.DeleteSwitch(sw.Id);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ namespace PluralKit.API
|
||||
public static PKError UnauthorizedGroupMemberList = new(403, 30003, "Unauthorized to view group member list");
|
||||
public static PKError UnauthorizedCurrentFronters = new(403, 30004, "Unauthorized to view current fronters.");
|
||||
public static PKError UnauthorizedFrontHistory = new(403, 30004, "Unauthorized to view front history.");
|
||||
public static PKError NotOwnMemberError = new(403, 40001, "Target member is not part of your system.");
|
||||
public static PKError NotOwnGroupError = new(403, 40002, "Target group is not part of your system.");
|
||||
public static PKError Unimplemented = new(501, 50001, "Unimplemented");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user