-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notification to org and person with resource working
- Loading branch information
Showing
31 changed files
with
286 additions
and
87 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
4 changes: 2 additions & 2 deletions
4
src/Notifications/API/Mappers/NotificationOrderRequestResponseMapper.cs
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
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
22 changes: 22 additions & 0 deletions
22
src/Notifications/Core/Integrations/IAuthorizationService.cs
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,22 @@ | ||
using Altinn.Notifications.Core.Models.ContactPoints; | ||
|
||
namespace Altinn.Notifications.Core.Integrations; | ||
|
||
/// <summary> | ||
/// Describes the necessary functions of an authorization service that can perform | ||
/// notification recipient filtering based on authorization | ||
/// </summary> | ||
public interface IAuthorizationService | ||
{ | ||
/// <summary> | ||
/// Describes a method that can create an authorization request to authorize a set of | ||
/// users for access to a resource. | ||
/// </summary> | ||
/// <param name="organizationContactPoints"> | ||
/// The contact points of an organization including user registered contact points. | ||
/// </param> | ||
/// <param name="resourceId">The id of the resource.</param> | ||
/// <returns>A new list of <see cref="OrganizationContactPoints"/> with filtered list of recipients.</returns> | ||
Task<List<OrganizationContactPoints>> AuthorizeUserContactPointsForResource( | ||
List<OrganizationContactPoints> organizationContactPoints, string resourceId); | ||
} |
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
74 changes: 74 additions & 0 deletions
74
src/Notifications/Core/Models/AltinnServiceUpdate/GenericServiceUpdate.cs
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,74 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
using Altinn.Notifications.Core.Enums; | ||
|
||
namespace Altinn.Notifications.Core.Models.AltinnServiceUpdate | ||
{ | ||
/// <summary> | ||
/// A class representing a generic service update | ||
/// </summary> | ||
public class GenericServiceUpdate | ||
{ | ||
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions() | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, | ||
WriteIndented = true, | ||
Converters = { new JsonStringEnumConverter() }, | ||
PropertyNameCaseInsensitive = true | ||
}; | ||
|
||
/// <summary> | ||
/// The source of the service update | ||
/// </summary> | ||
public string Source { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// The schema of the service update data | ||
/// </summary> | ||
public AltinnServiceUpdateSchema Schema { get; set; } | ||
|
||
/// <summary> | ||
/// The data of the service update as a json serialized string | ||
/// </summary> | ||
public string Data { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Serialize the <see cref="GenericServiceUpdate"/> into a json string | ||
/// </summary> | ||
/// <returns></returns> | ||
public string Serialize() | ||
{ | ||
return JsonSerializer.Serialize(this, _serializerOptions); | ||
} | ||
|
||
/// <summary> | ||
/// Try to parse a json string into a<see cref="GenericServiceUpdate"/> | ||
/// </summary> | ||
public static bool TryParse(string input, out GenericServiceUpdate value) | ||
{ | ||
GenericServiceUpdate? parsedOutput; | ||
value = new GenericServiceUpdate(); | ||
|
||
if (string.IsNullOrEmpty(input)) | ||
{ | ||
return false; | ||
} | ||
|
||
try | ||
{ | ||
parsedOutput = JsonSerializer.Deserialize<GenericServiceUpdate>(input!, _serializerOptions); | ||
|
||
value = parsedOutput!; | ||
return !string.IsNullOrEmpty(value.Source); | ||
} | ||
catch | ||
{ | ||
// try parse, we simply return false if fails | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/Notifications/Core/Models/AltinnServiceUpdate/ResourceLimitExceeded.cs
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,67 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Altinn.Notifications.Core.Models.AltinnServiceUpdate | ||
{ | ||
/// <summary> | ||
/// A class holding data on an exceeded resource limit in an Altinn service | ||
/// </summary> | ||
public class ResourceLimitExceeded | ||
{ | ||
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions() | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, | ||
WriteIndented = true, | ||
Converters = { new JsonStringEnumConverter() }, | ||
PropertyNameCaseInsensitive = true | ||
}; | ||
|
||
/// <summary> | ||
/// The resource that has reached its capacity limit | ||
/// </summary> | ||
public string Resource { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// The timestamp for when the service is available again | ||
/// </summary> | ||
public DateTime ResetTime { get; set; } | ||
|
||
/// <summary> | ||
/// Serialize the <see cref="ResourceLimitExceeded"/> into a json string | ||
/// </summary> | ||
/// <returns></returns> | ||
public string Serialize() | ||
{ | ||
return JsonSerializer.Serialize(this, _serializerOptions); | ||
} | ||
|
||
/// <summary> | ||
/// Try to parse a json string into a<see cref="ResourceLimitExceeded"/> | ||
/// </summary> | ||
public static bool Tryparse(string input, out ResourceLimitExceeded value) | ||
{ | ||
ResourceLimitExceeded? parsedOutput; | ||
value = new ResourceLimitExceeded(); | ||
|
||
if (string.IsNullOrEmpty(input)) | ||
{ | ||
return false; | ||
} | ||
|
||
try | ||
{ | ||
parsedOutput = JsonSerializer.Deserialize<ResourceLimitExceeded>(input!, _serializerOptions); | ||
|
||
value = parsedOutput!; | ||
return !string.IsNullOrEmpty(value.Resource); | ||
} | ||
catch | ||
{ | ||
// try parse, we simply return false if fails | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
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
1 change: 0 additions & 1 deletion
1
src/Notifications/Core/Models/NotificationTemplate/SmsTemplate.cs
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 |
---|---|---|
|
@@ -122,4 +122,4 @@ public static bool TryParse(string input, out NotificationOrder value) | |
|
||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.