diff --git a/BMA.EHR.Placement.Service/Controllers/NotifyController.cs b/BMA.EHR.Placement.Service/Controllers/NotifyController.cs index 23959e2a..63f01670 100644 --- a/BMA.EHR.Placement.Service/Controllers/NotifyController.cs +++ b/BMA.EHR.Placement.Service/Controllers/NotifyController.cs @@ -72,6 +72,47 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + [HttpPost("keycloak")] + public async Task> UpdatePropertyByUserKeycloak([FromBody] NotiRequest req) + { + var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId); + if (profile == null) + return Error(GlobalMessages.DataNotFound); + + await _repositoryNoti.PushNotificationAsync( + profile.Id, + req.Subject, + req.Body, + req.Payload, + req.IsSendInbox, + req.IsSendMail + ); + + return Success(); + } + + [HttpPut("{id:length(36)}")] + public async Task> ReplyPropertyByUser([FromBody] NotiReplyRequest req, Guid id) + { + var inbox = await _context.Inboxes.FirstOrDefaultAsync(x => x.Id == id); + if (inbox == null) + return Error(GlobalMessages.DataNotFound); + var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(inbox.CreatedUserId)); + if (profile == null) + return Error(GlobalMessages.DataNotFound); + + await _repositoryNoti.PushNotificationAsync( + profile.Id, + req.Subject, + req.Body, + req.Payload, + req.IsSendInbox, + req.IsSendMail + ); + + return Success(); + } + [HttpPost("cronjob")] public async Task> CornjobProbation([FromBody] NotiCronjobProbationRequest req) { diff --git a/BMA.EHR.Placement.Service/Requests/NotiReplyRequest.cs b/BMA.EHR.Placement.Service/Requests/NotiReplyRequest.cs new file mode 100644 index 00000000..f60e0f04 --- /dev/null +++ b/BMA.EHR.Placement.Service/Requests/NotiReplyRequest.cs @@ -0,0 +1,15 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Placement.Service.Requests +{ + public class NotiReplyRequest + { + public string Subject { get; set; } = ""; + public string Body { get; set; } = ""; + public string Payload { get; set; } = ""; + public bool IsSendMail { get; set; } = true; + public bool IsSendInbox { get; set; } = true; + public bool IsSendNotification { get; set; } = true; + } +}