Skip to content

Commit

Permalink
Fix ON.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Sep 13, 2023
1 parent c6d5bfd commit 5b5a237
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class IntegratedMessageBirdIntegration : IIntegration, ISmsSender,
new IntegrationDefinition(
"MessageBirdIntegrated",
Texts.MessageBirdIntegrated_Name,
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 66 55' fill='#fff' fill-rule='evenodd' stroke='#000' stroke-linecap='round' stroke-linejoin='round'><use xlink:href='#A' x='.5' y='.5'/><symbol id='A' overflow='visible'><path d='M57.425 9.57c-2.568 0-4.863 1.284-6.264 3.23l-9.454 13.228a1.9 1.9 0 0 1-1.556.817 1.91 1.91 0 0 1-1.906-1.906c0-.39.117-.778.31-1.05l7.975-11.945c.817-1.206 1.284-2.684 1.284-4.28C47.814 3.424 44.39 0 40.15 0H0v7.664h34.393c0 2.1-1.712 3.852-3.852 3.852H0c0 2.723.584 5.33 1.595 7.664H26.69c0 2.1-1.712 3.852-3.852 3.852H3.852a19.12 19.12 0 0 0 15.368 7.664h9.454a1.91 1.91 0 0 1 1.906 1.906 1.91 1.91 0 0 1-1.906 1.906H19.18L6.34 53.688h23.227c10.62 0 19.647-6.925 22.8-16.496l4.32-13.11c1.4-4.24 3.968-7.976 7.314-10.816-1.323-2.218-3.774-3.696-6.575-3.696zm0 5.252c-.778 0-1.44-.66-1.44-1.44a1.46 1.46 0 0 1 1.44-1.44 1.46 1.46 0 0 1 1.44 1.44c0 .817-.66 1.44-1.44 1.44z' stroke='none' fill='#2481d7' fill-rule='nonzero'/></symbol></svg>",
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 66 55' fill='#fff' fill-rule='evenodd' stroke='#000' stroke-linecap='round' stroke-linejoin='round'><use xlink:href='#A' x='.5' y='.5'/><symbol id='a' overflow='visible'><path d='M57.425 9.57c-2.568 0-4.863 1.284-6.264 3.23l-9.454 13.228a1.9 1.9 0 0 1-1.556.817 1.91 1.91 0 0 1-1.906-1.906c0-.39.117-.778.31-1.05l7.975-11.945c.817-1.206 1.284-2.684 1.284-4.28C47.814 3.424 44.39 0 40.15 0H0v7.664h34.393c0 2.1-1.712 3.852-3.852 3.852H0c0 2.723.584 5.33 1.595 7.664H26.69c0 2.1-1.712 3.852-3.852 3.852H3.852a19.12 19.12 0 0 0 15.368 7.664h9.454a1.91 1.91 0 0 1 1.906 1.906 1.91 1.91 0 0 1-1.906 1.906H19.18L6.34 53.688h23.227c10.62 0 19.647-6.925 22.8-16.496l4.32-13.11c1.4-4.24 3.968-7.976 7.314-10.816-1.323-2.218-3.774-3.696-6.575-3.696zm0 5.252c-.778 0-1.44-.66-1.44-1.44a1.46 1.46 0 0 1 1.44-1.44 1.46 1.46 0 0 1 1.44 1.44c0 .817-.66 1.44-1.44 1.44z' stroke='none' fill='#2481d7' fill-rule='nonzero'/></symbol></svg>",
new List<IntegrationProperty>(),
new List<IntegrationProperty>(),
new HashSet<string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public abstract class OpenNotificationsIntegrationBase : IIntegration

protected OpenNotificationsIntegrationBase(string fullName, string providerName, ProviderInfoDto providerInfo, IOpenNotificationsClient client)
{
var capabilities = new HashSet<string>
{
"Open Notifications"
};
var capabilities = new HashSet<string>();

if (providerInfo.Type == ProviderInfoDtoType.Sms)
{
Expand All @@ -38,6 +35,8 @@ protected OpenNotificationsIntegrationBase(string fullName, string providerName,
capabilities.Add(Providers.Email);
}

capabilities.Add("Open Notifications");

var hasSummaryProperty = providerInfo.Properties.Any(x => x.Value.Summary);

bool MakeSummary(PropertyInfoDto property)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================

using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using Notifo.Infrastructure.Timers;
Expand All @@ -16,9 +15,19 @@ namespace Notifo.Domain.Integrations.OpenNotifications;

public sealed class OpenNotificationsRegistry : IIntegrationRegistry, IBackgroundProcess
{
private readonly ConcurrentDictionary<string, IIntegration> integrations = new ConcurrentDictionary<string, IIntegration>();
private static readonly HashSet<string> ProvidersToIgnore = new HashSet<string>
{
"aws-email",
"mailjet",
"mailjet-smtp",
"messagebird-sms",
"smtp",
"twilio-sms",
};

private readonly IEnumerable<IOpenNotificationsClient> clients;
private readonly ILogger<OpenNotificationsRegistry> log;
private Dictionary<string, IIntegration> integrations = new Dictionary<string, IIntegration>();
private CompletionTimer timer;

public IEnumerable<IIntegration> Integrations => integrations.Values;
Expand Down Expand Up @@ -63,26 +72,40 @@ private async Task QueryClientAsync(IOpenNotificationsClient client, Cancellatio

var providers = await client.Providers.GetProvidersAsync(request, ct);

foreach (var (name, providerInfo) in providers.Providers)
{
var fullName = $"{client.Name}_{name}";

if (providerInfo.Type == ProviderInfoDtoType.Sms)
{
integrations.TryAdd(fullName, new OpenNotificationsSmsIntegration(fullName, name, providerInfo, client));
}
else if (providerInfo.Type == ProviderInfoDtoType.Email)
{
integrations.TryAdd(fullName, new OpenNotificationsEmailIntegration(fullName, name, providerInfo, client));
}
}
integrations = BuildIntegrations(client, providers);
}
catch (Exception ex)
{
log.LogWarning(ex, "Failed to query providers from {name}", client.Name);
}
}

private static Dictionary<string, IIntegration> BuildIntegrations(IOpenNotificationsClient client, GetProvidersResponseDto providers)
{
var newIntegrations = new Dictionary<string, IIntegration>();

foreach (var (name, providerInfo) in providers.Providers)
{
if (ProvidersToIgnore.Contains(name))
{
continue;
}

var fullName = $"{client.Name}_{name}";

if (providerInfo.Type == ProviderInfoDtoType.Sms)
{
newIntegrations.TryAdd(fullName, new OpenNotificationsSmsIntegration(fullName, name, providerInfo, client));
}
else if (providerInfo.Type == ProviderInfoDtoType.Email)
{
newIntegrations.TryAdd(fullName, new OpenNotificationsEmailIntegration(fullName, name, providerInfo, client));
}
}

return newIntegrations;
}

public bool TryGetIntegration(string type, [MaybeNullWhen(false)] out IIntegration integration)
{
return integrations.TryGetValue(type, out integration);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions backend/src/Notifo.Domain.Integrations/Resources/Texts.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<value>Email address {0} is already used by another app.</value>
</data>
<data name="Email_AdditionalFromEmailsDescription" xml:space="preserve">
<value>Comma or line-separated list of additional email-addresses</value>
<value>Comma or line-separated list of additional email-addresses.</value>
</data>
<data name="Email_AdditionalFromEmailsLabel" xml:space="preserve">
<value>Email Addresses</value>
Expand Down Expand Up @@ -163,13 +163,13 @@
<value>Project ID</value>
</data>
<data name="Firebase_SilentAndroidDescription" xml:space="preserve">
<value>Send silent notifications to Android</value>
<value>Send silent notifications to Android.</value>
</data>
<data name="Firebase_SilentAndroidLabel" xml:space="preserve">
<value>Silent (Android)</value>
</data>
<data name="Firebase_SilentIOSDescription" xml:space="preserve">
<value>Send silent notifications to iOS</value>
<value>Send silent notifications to iOS.</value>
</data>
<data name="Firebase_SilentIOSLabel" xml:space="preserve">
<value>Silent (iOS)</value>
Expand Down Expand Up @@ -280,7 +280,7 @@
<value>Host</value>
</data>
<data name="SMTP_Name" xml:space="preserve">
<value>Custom SMTP Server</value>
<value>SMTP Server</value>
</data>
<data name="SMTP_PasswordHints" xml:space="preserve">
<value>Password for your SMTP server.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public sealed partial class SmtpIntegration : IIntegration
new IntegrationDefinition(
"SMTP",
Texts.SMTP_Name,
"<svg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' viewBox='0 0 86.205 56.127'><path d='M86.126 55.085c.047-.145.079-.298.079-.459V1.499c0-.162-.032-.316-.08-.462-.007-.02-.011-.04-.019-.06a1.492 1.492 0 0 0-.276-.46c-.008-.009-.009-.02-.017-.029-.005-.005-.011-.007-.016-.012a1.504 1.504 0 0 0-.442-.323c-.013-.006-.023-.014-.036-.02a1.48 1.48 0 0 0-.511-.123c-.018-.001-.035-.005-.053-.005C84.738.004 84.723 0 84.706 0H1.501c-.017 0-.033.004-.05.005L1.403.01a1.497 1.497 0 0 0-.518.125C.875.139.867.146.857.15.687.231.536.341.409.477.404.482.398.483.393.488.385.496.384.507.376.516a1.5 1.5 0 0 0-.277.461c-.008.02-.012.04-.019.061-.048.146-.08.3-.08.462v53.128c0 .164.033.32.082.468l.018.059a1.5 1.5 0 0 0 .28.462c.007.008.009.018.016.026.006.007.014.011.021.018.049.051.103.096.159.14.025.019.047.042.073.06.066.046.137.083.21.117.018.008.034.021.052.028.181.077.38.121.589.121h83.204c.209 0 .408-.043.589-.121.028-.012.054-.03.081-.044.062-.031.124-.063.181-.102.03-.021.057-.048.086-.071.051-.041.101-.082.145-.129l.025-.022c.008-.009.01-.021.018-.03a1.5 1.5 0 0 0 .275-.458c.01-.022.015-.043.022-.065zM3.001 4.901l25.247 23.061L3.001 51.207Zm51.746 21.931c-.104.068-.214.125-.301.221-.033.036-.044.083-.073.121l-11.27 10.294L5.367 2.999h75.472zm-24.275 3.161 11.619 10.613a1.496 1.496 0 0 0 2.023 0l11.475-10.481 25.243 23.002H5.345Zm27.342-1.9L83.205 4.901v46.33z'/></svg>",
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' xml:space='preserve'><linearGradient id='a' gradientUnits='userSpaceOnUse' x1='256' y1='347.889' x2='256' y2='0'><stop offset='0' style='stop-color:#cf993f'/><stop offset='.768' style='stop-color:#dfa34f'/></linearGradient><path style='fill:url(#a)' d='M511.972 170.467v11.507c-.6.427-1.372.937-2.143 1.448l-19.117 13.041c-1.285.853-2.828 1.875-4.371 2.984-7.973 5.283-18.345 12.358-25.203 16.876L293.376 329.769l-5.315 3.58-15.602 10.569c-1.972 1.278-4.286 2.301-6.858 2.983-1.029.34-2.229.511-3.343.681-.172.085-.343.085-.428.085-1.972.256-3.943.256-5.83.171-1.886.085-3.857.085-5.829-.171a27.086 27.086 0 0 1-3.772-.767c-2.572-.681-4.886-1.705-6.858-2.983l-7.029-4.774-8.572-5.795L50.862 216.324a276.656 276.656 0 0 0-6.429-4.262c-6-4.006-13.03-8.779-18.774-12.614-1.543-1.109-3.086-2.131-4.372-2.984L2.171 183.423c-.771-.511-1.543-1.022-2.143-1.448v-11.507c0-1.96.257-3.494.686-4.943 0-.084.086-.084.086-.084.429-.341.857-.597 1.371-.939l6.172-4.262 12.944-8.779c8.143-5.454 21.431-14.489 29.574-19.859L239.541 4.007C244.085 1.109 250.085-.255 256 .086c.6 0 1.114-.085 1.715-.085h.086c5.315 0 10.63 1.365 14.659 4.007l188.679 127.594c6.772 4.432 17.059 11.421 25.031 16.792 1.629 1.107 3.172 2.131 4.543 3.067l12.944 8.779 6.172 4.262c.514.341.943.597 1.371.939.515 1.447.772 3.066.772 5.026z'/><linearGradient id='b' gradientUnits='userSpaceOnUse' x1='256' y1='398.917' x2='256' y2='51.064'><stop offset='0' style='stop-color:#cf993f'/><stop offset='.768' style='stop-color:#dfa34f'/></linearGradient><path style='fill:url(#b)' d='M512 221.49v11.441c-.625.443-1.429.976-2.141 1.508l-19.179 13.037c-8.116 5.41-21.407 14.455-29.524 19.866L272.502 394.875c-2.051 1.33-4.371 2.305-6.868 3.015-3.032.887-6.422 1.153-9.633.975-3.211.178-6.601-.089-9.633-.975-2.498-.71-4.817-1.685-6.868-3.015L50.845 267.341c-8.117-5.411-21.408-14.456-29.524-19.866L2.142 234.439c-.712-.533-1.516-1.065-2.141-1.508V221.49c0-1.951.268-3.548.714-4.966 0-.089.089-.089.089-.089.446-.355.892-.622 1.337-.977l6.245-4.257 12.934-8.78c8.116-5.41 21.407-14.455 29.524-19.866L239.499 55.023c4.549-2.927 10.614-4.258 16.501-3.903 5.887-.355 12.042.975 16.501 3.903l188.655 127.532c8.117 5.411 21.408 14.456 29.524 19.866l12.934 8.78 6.245 4.257c.445.355.891.621 1.337.977.536 1.418.804 3.104.804 5.055z'/><path style='fill:#c0874a' d='M262.258 314.513v35.968h-1.029l-11.487.767H.028V173.792c0-1.96.257-3.58.686-4.944 0-.085.086-.085.086-.085.943-2.983 2.829-4.688 5.315-5.114l10.716 6.307 5.057 2.983 23.06 13.553 1.2.681 14.659 8.609 166.819 98.359.343.171 33.089 19.433 1.2.768z'/><path style='fill:#f0ba7d' d='M266.715 336.247c0 .085-1.714 1.279-4.457 3.239a177.152 177.152 0 0 0-6.258 4.262c-1.2.767-2.486 1.619-3.857 2.557l-1.972 1.363-3.772 2.557-1.629 1.023-26.66 17.984c-2.829 1.875-5.658 3.835-8.229 5.626-4.886 3.324-8.916 6.051-10.287 6.903-1.972 1.449-10.201 6.99-18.345 12.529l-44.577 30.088-.172.171-.085.085-109.384 73.813c-1.886 1.279-3.943 2.642-5.915 4.006-1.115.767-2.229 1.449-3.343 2.216H8.515c-4.972 0-7.801-1.108-8.401-2.983v-.085c0-.341-.086-.597 0-1.023-.086-.512-.086-1.023-.086-1.62V173.792c0-1.96.257-3.58.686-4.944 0-.085.086-.085.086-.085.943-2.983 2.829-4.688 5.315-5.114.771-.256 1.457-.256 2.229-.171 1.886.085 4.029.938 6.344 2.472l30.346 20.456 1.114.767 13.116 8.864.771.512c8.058 5.455 20.745 14.064 28.632 19.348l153.446 103.729c.172.085.343.171.429.256l.771.512c2.057 1.363 4.029 2.728 5.829 3.92 3.001 1.96 5.401 3.665 6.858 4.688.857.512 1.458.852 1.543.937.343.255 2.486 1.705 4.715 3.324.086 0 .086.085.171.085 2.315 1.62 4.286 2.813 4.286 2.899z'/><path style='fill:#e5a864' d='M511.865 171.974c.074 1 .134 2.92.134 4.267v323.257c0 .317-.089 1.248-.089 1.419V501.627c0 .024-.783.723-1.74 1.551-.957.829-7.747 1.507-9.094 1.507h-4.378c-1.347 0-3.365-.612-4.486-1.359l-5.204-3.489c-1.12-.748-2.95-1.976-4.066-2.731L332.776 395.641l-4.058-2.742-14.324-9.753a1373.46 1373.46 0 0 0-4.05-2.754l-14.412-9.754a1252.76 1252.76 0 0 0-4.055-2.747l-24.216-16.33-4.062-2.736-1.734-1.167a847.668 847.668 0 0 0-4.072-2.72s-.635-.421-1.795-1.219c-6.155-4.257-10.704-7.362-10.704-7.451 0-.089 1.963-1.329 4.282-2.926 2.318-1.597 2.885-1.986 2.885-1.986a337.009 337.009 0 0 0 2.332-1.607c.172-.122 2.109-1.383 3.214-2.152 0 0 5.125-3.567 10.657-7.204l.268-.178.668-.443c.073-.049.954-.617 1.74-1.153.785-.536 2.341-1.592 3.457-2.346l146.508-98.984a3606.7 3606.7 0 0 0 4.056-2.745l25.377-17.123a5759.21 5759.21 0 0 0 4.06-2.739l40.451-27.324c1.116-.754 3-1.892 4.187-2.529 0 0 1.065-.637 2.169-.881s3.079-.189 4.389.123l3.792 2.662c.776 1.103 2.005 4.241 2.079 5.241z'/><path style='fill:#c0874a' d='M511.999 458.657v40.265c0 .62 0 1.153-.089 1.685.089.355 0 .621 0 .976v.089c-.625 1.862-3.48 3.014-8.385 3.014H46.383l90.001-80.084.089-.089L249.13 324.297l10.972-9.668 2.942-2.661 9.723 5.677 239.232 141.012z'/><path style='fill:#ecb168' d='M511.999 497.414v1.508c0 .62 0 1.153-.089 1.685.089.355 0 .621 0 .976v.089c-.625 1.862-3.48 3.014-8.385 3.014H8.474c-4.905 0-7.76-1.152-8.385-3.014v-.089c0-.355-.089-.621 0-.976C0 500.075 0 499.542 0 498.922v-1.508c.803-1.064 1.963-2.128 3.479-3.193l238.07-173.651c.089 0 .089-.088.179-.176l.803-.532c4.905-3.46 9.901-5.855 13.469-6.74 1.249.354 2.586.797 4.104 1.507 2.854 1.153 6.154 3.016 9.365 5.233.356.265.624.443.981.708l238.069 173.651c1.516 1.153 2.676 2.217 3.48 3.193z'/></svg>",
new List<IntegrationProperty>
{
HostProperty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public sealed partial class TelegramIntegration : IIntegration
new IntegrationDefinition(
"Telegram",
Texts.Telegram_Name,
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'><defs><linearGradient id='a' x1='.667' x2='.417' y1='.167' y2='.75'><stop offset='0' stop-color='#37aee2'/><stop offset='1' stop-color='#1e96c8'/></linearGradient><linearGradient id='b' x1='.66' x2='.851' y1='.437' y2='.802'><stop offset='0' stop-color='#eff7fc'/><stop offset='1' stop-color='#fff'/></linearGradient></defs><circle cx='120' cy='120' r='120' fill='url(#a)'/><path fill='#c8daea' d='M98 175c-3.888 0-3.227-1.468-4.568-5.17L82 132.207 170 80'/><path fill='#a9c9dd' d='M98 175c3 0 4.325-1.372 6-3l16-15.558-19.958-12.035'/><path fill='url(#b)' d='M100.04 144.41l48.36 35.729c5.519 3.045 9.501 1.468 10.876-5.123l19.685-92.763c2.015-8.08-3.08-11.746-8.36-9.349l-115.59 44.571c-7.89 3.165-7.843 7.567-1.438 9.528l29.663 9.259 68.673-43.325c3.242-1.966 6.218-.91 3.776 1.258'/></svg>",
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'><defs><linearGradient id='a' x1='120' y1='240' x2='120' gradientUnits='userSpaceOnUse'><stop offset='0' stop-color='#1d93d2'/><stop offset='1' stop-color='#38b0e3'/></linearGradient></defs><circle cx='120' cy='120' r='120' fill='url(#a)'/><path d='m81.229 128.772 14.237 39.406s1.78 3.687 3.686 3.687 30.255-29.492 30.255-29.492l31.525-60.89L81.737 118.6Z' fill='#c8daea'/><path d='m100.106 138.878-2.733 29.046s-1.144 8.9 7.754 0 17.415-15.763 17.415-15.763' fill='#a9c6d8'/><path d='M81.486 130.178 52.2 120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229 2.1-2.2 6.489-4.523 120.106-45.36 120.106-45.36s3.208-1.081 5.1-.362a2.766 2.766 0 0 1 1.885 2.055 9.357 9.357 0 0 1 .254 2.585c-.009.752-.1 1.449-.169 2.542-.692 11.165-21.4 94.493-21.4 94.493s-1.239 4.876-5.678 5.043a8.13 8.13 0 0 1-5.925-2.292c-8.711-7.493-38.819-27.727-45.472-32.177a1.27 1.27 0 0 1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6 53.821-51.492c.108-.379-.3-.566-.848-.4-3.482 1.281-63.844 39.4-70.506 43.607a3.21 3.21 0 0 1-1.48.09Z' fill='#fff'/></svg>",
new List<IntegrationProperty>
{
AccessToken
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/app/framework/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ export module Numbers {

return ((u ? `${value.toFixed(1)} ` : value) + ' kMGTPEZY'[u]).trim();
}

export function guid(): string {
return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
}

export function s4(): string {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
}
Loading

0 comments on commit 5b5a237

Please sign in to comment.