💥 Updated subscription API
This commit is contained in:
@@ -15,13 +15,6 @@ public class PublisherSubscriptionController(
|
|||||||
)
|
)
|
||||||
: ControllerBase
|
: ControllerBase
|
||||||
{
|
{
|
||||||
public class SubscriptionStatusResponse
|
|
||||||
{
|
|
||||||
public bool IsSubscribed { get; set; }
|
|
||||||
public Guid PublisherId { get; set; }
|
|
||||||
public string PublisherName { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SubscribeRequest
|
public class SubscribeRequest
|
||||||
{
|
{
|
||||||
public int? Tier { get; set; }
|
public int? Tier { get; set; }
|
||||||
@@ -29,7 +22,7 @@ public class PublisherSubscriptionController(
|
|||||||
|
|
||||||
[HttpGet("{name}/subscription")]
|
[HttpGet("{name}/subscription")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult<SubscriptionStatusResponse>> CheckSubscriptionStatus(string name)
|
public async Task<ActionResult<SnPublisherSubscription>> CheckSubscriptionStatus(string name)
|
||||||
{
|
{
|
||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||||
|
|
||||||
@@ -38,14 +31,9 @@ public class PublisherSubscriptionController(
|
|||||||
if (publisher == null)
|
if (publisher == null)
|
||||||
return NotFound("Publisher not found");
|
return NotFound("Publisher not found");
|
||||||
|
|
||||||
var isSubscribed = await subs.SubscriptionExistsAsync(Guid.Parse(currentUser.Id), publisher.Id);
|
var subscription = await subs.GetSubscriptionAsync(Guid.Parse(currentUser.Id), publisher.Id);
|
||||||
|
if (subscription is null) return NotFound("Subscription not found");
|
||||||
return new SubscriptionStatusResponse
|
return subscription;
|
||||||
{
|
|
||||||
IsSubscribed = isSubscribed,
|
|
||||||
PublisherId = publisher.Id,
|
|
||||||
PublisherName = publisher.Name
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{name}/subscribe")]
|
[HttpPost("{name}/subscribe")]
|
||||||
|
|||||||
Reference in New Issue
Block a user