Skip to content

Commit

Permalink
Merge branch 'main' of github.com:masastack/MASA.Alert
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 committed Sep 4, 2024
2 parents caba51d + 920e492 commit 5481e16
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<MasaFrameworkPackageVersion>1.2.0-preview.2</MasaFrameworkPackageVersion>
<MasaStackSdksPackageVersion>1.1.1-preview.7</MasaStackSdksPackageVersion>
<MasaStackSdksPackageVersion>1.2.1-preview.4</MasaStackSdksPackageVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private async Task AddLogVariablesAsync(AlarmRule alarmRule, Dictionary<string,
Query = alarmRule.WhereExpression,
Start = startTime.Value.UtcDateTime,
End = checkTime.UtcDateTime,
Service = alarmRule.AppIdentity,
IsDesc = true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ public McNotificationSender(IMcClient mcClient)
}
public async Task SendAsync(NotificationConfig notificationConfig, Dictionary<string, object> variables)
{
if (!notificationConfig.Receivers.Any())
var channelType = (ChannelTypes)notificationConfig.ChannelType;

SendTargets? receiverType = notificationConfig.Receivers.Any()
? SendTargets.Assign
: channelType == ChannelTypes.WeixinWorkWebhook
? SendTargets.Broadcast
: null;

if (receiverType == null)
{
return;
}
Expand All @@ -23,8 +31,9 @@ public async Task SendAsync(NotificationConfig notificationConfig, Dictionary<st
ChannelCode = notificationConfig.ChannelCode,
ChannelType = (ChannelTypes)notificationConfig.ChannelType,
TemplateCode = notificationConfig.TemplateCode,
ReceiverType = SendTargets.Assign,
Receivers = notificationConfig.Receivers.Select(x => new InternalReceiverModel {
ReceiverType = receiverType.Value,
Receivers = notificationConfig.Receivers.Select(x => new InternalReceiverModel
{
Type = MessageTaskReceiverTypes.User,
SubjectId = x
}).ToList(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@
<ProjectReference Include="..\..\Infrastructure\Masa.Alert.Infrastructure.Middleware\Masa.Alert.Infrastructure.Middleware.csproj" />
<ProjectReference Include="..\..\Infrastructure\Masa.Alert.NotificationService.Provider.Mc\Masa.Alert.NotificationService.Provider.Mc.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>
</Project>
21 changes: 8 additions & 13 deletions src/Services/Masa.Alert.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@
await builder.Services.AddMasaStackConfigAsync(MasaStackProject.Alert, MasaStackApp.Service);
var masaStackConfig = builder.Services.GetMasaStackConfig();

builder.Services.AddAlertObservable(builder.Logging, () =>
builder.Services.AddObservable(builder.Logging, new MasaObservableOptions
{
return new MasaObservableOptions
{
ServiceNameSpace = builder.Environment.EnvironmentName,
ServiceVersion = masaStackConfig.Version,
ServiceName = masaStackConfig.GetServiceId(MasaStackProject.Alert),
Layer = masaStackConfig.Namespace,
ServiceInstanceId = builder.Configuration.GetValue<string>("HOSTNAME")
};
}, () =>
{
return masaStackConfig.OtlpUrl;
});
ServiceNameSpace = builder.Environment.EnvironmentName,
ServiceVersion = masaStackConfig.Version,
ServiceName = masaStackConfig.GetServiceId(MasaStackProject.Alert),
Layer = masaStackConfig.Namespace,
ServiceInstanceId = builder.Configuration.GetValue<string>("HOSTNAME")!
}
, masaStackConfig.OtlpUrl, activitySources: new string[] { CheckAlarmRuleJob.ActivitySource.Name });

builder.Services.AddDaprClient();
var identityServerUrl = masaStackConfig.GetSsoDomain();
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Masa.Alert.Service/_Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
global using Masa.BuildingBlocks.Extensions.BackgroundJobs;
global using Masa.BuildingBlocks.RulesEngine;
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts;
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Consts;
global using Masa.BuildingBlocks.StackSdks.Config.Consts;
global using Masa.Contrib.Caching.Distributed.StackExchangeRedis;
global using Masa.Contrib.Configuration.ConfigurationApi.Dcc;
global using Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EFCore;
Expand Down

0 comments on commit 5481e16

Please sign in to comment.