-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first draft sub * Fix notification * Update core/Controllers/SubscriptionController.cs Co-authored-by: Camille Brulotte <[email protected]> * Update core/Controllers/SubscriptionController.cs Co-authored-by: Camille Brulotte <[email protected]> * Update core/Data/Entities/Notification.cs Co-authored-by: Camille Brulotte <[email protected]> * Update core/Misc/SchedulerSetup.cs Co-authored-by: Camille Brulotte <[email protected]> * Update core/Services/NotificationService.cs Co-authored-by: Camille Brulotte <[email protected]> * Update core/Services/NotificationService.cs Co-authored-by: Camille Brulotte <[email protected]> * Update core/Services/NotificationService.cs * Update core/Services/SubscriptionService.cs * Update core/Services/NotificationService.cs * Update emails/Services/Abstractions/IEmailService.cs * Update emails/Services/EmailService.cs * Add loggers * fix varying log * change to use environement variable from conf * Add tests * Fix tests and add asserts * fix security issue --------- Co-authored-by: Camille Brulotte <[email protected]>
- Loading branch information
1 parent
36d68c2
commit 4ea095d
Showing
35 changed files
with
1,916 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using api.core.Data; | ||
using api.core.Data.requests; | ||
using api.core.Services.Abstractions; | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace api.core.Controllers; | ||
|
||
[ApiController] | ||
[Route("api/subscriptions")] | ||
public class SubscriptionController(ISubscriptionService subscriptionService) : ControllerBase | ||
{ | ||
[HttpPost] | ||
public IActionResult Subscribe([FromBody] SubscribeRequestDTO request) | ||
{ | ||
subscriptionService.Subscribe(request); | ||
return Ok(new Response<object> | ||
{ | ||
Data = "Subscribed successfully to this organizer posts." | ||
}); | ||
} | ||
|
||
[HttpDelete] | ||
public IActionResult Unsubcribe([FromBody] UnsubscribeRequestDTO request) | ||
{ | ||
subscriptionService.Unsubscribe(request); | ||
return Ok(new Response<object> | ||
{ | ||
Data = "Unsubscribed successfully from this organizer posts." | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
using api.core.Data.Entities; | ||
|
||
namespace api.core.data.entities; | ||
|
||
[Table(nameof(Notification))] | ||
public partial class Notification : BaseEntity | ||
{ | ||
public Guid PublicationId { get; set; } | ||
|
||
public Guid SubscriptionId { get; set; } | ||
|
||
public bool IsSent { get; set; } = false; | ||
|
||
[ForeignKey(nameof(PublicationId))] | ||
[InverseProperty(nameof(Publication.Notifications))] | ||
public virtual Publication Publication { get; set; } = null!; | ||
|
||
[ForeignKey(nameof(SubscriptionId))] | ||
[InverseProperty(nameof(Subscription.Notifications))] | ||
public virtual Subscription Subscription { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
using api.core.Data.Entities; | ||
|
||
|
||
namespace api.core.data.entities; | ||
|
||
[Table(nameof(Subscription))] | ||
public partial class Subscription : BaseEntity | ||
{ | ||
public string Email { get; set; } = null!; | ||
|
||
public Guid OrganizerId { get; set; } | ||
|
||
public string SubscriptionToken { get; set; } = null!; | ||
|
||
[ForeignKey(nameof(OrganizerId))] | ||
[InverseProperty(nameof(entities.Organizer.Subscriptions))] | ||
public virtual Organizer Organizer { get; set; } = null!; | ||
|
||
[InverseProperty(nameof(Notification.Subscription))] | ||
public virtual ICollection<Notification> Notifications { get; set; } = new List<Notification>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace api.core.Data.requests; | ||
|
||
public class SubscribeRequestDTO | ||
{ | ||
public required string Email { get; set; } | ||
|
||
public required Guid OrganizerId { get; set; } | ||
} | ||
|
||
|
||
public class UnsubscribeRequestDTO | ||
{ | ||
public required string SubscriptionToken { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.