Skip to content

Commit eac4920

Browse files
authored
Merge pull request #60 from GarageGroup/feature/use-english
Feature/use english
2 parents 28af975 + 1993333 commit eac4920

38 files changed

+303
-281
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using GarageGroup.Infra;
2+
using GarageGroup.Infra.Bot.Builder;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using PrimeFuncPack;
5+
6+
namespace GarageGroup.Internal.Timesheet;
7+
8+
partial class Application
9+
{
10+
[HttpFunction("HandleProactiveMessage", HttpMethodName.Post, Route = "proactiveMessage", AuthLevel = HttpAuthorizationLevel.Function)]
11+
internal static Dependency<IProactiveMessageHandler> UseProactiveMessageHandler()
12+
=>
13+
Dependency.From(
14+
StandardCloudAdapter.Resolve,
15+
ServiceProviderServiceExtensions.GetRequiredService<ICosmosStorage>)
16+
.UseProactiveMessageHandler();
17+
}

src/app/AzureFunc/Applicaton/Applicaton.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using GarageGroup.Infra;
4+
using GarageGroup.Infra.Bot.Builder;
45
using Microsoft.Extensions.Configuration;
56
using Microsoft.Extensions.DependencyInjection;
67
using PrimeFuncPack;
@@ -26,6 +27,12 @@ private static Dependency<ICrmTimesheetApi> UseCrmTimesheetApi()
2627
ResolveTimesheetApiOption)
2728
.UseCrmTimesheetApi();
2829

30+
private static Dependency<IUserAuthorizationApi> UseUserAuthorizationApi()
31+
=>
32+
Dependency.From(
33+
ServiceProviderServiceExtensions.GetRequiredService<IDataverseApiClient>)
34+
.UseUserAuthorizationApi();
35+
2936
private static CrmTimesheetApiOption ResolveTimesheetApiOption(IServiceProvider serviceProvider)
3037
{
3138
var section = serviceProvider.GetConfiguration().GetRequiredSection("CrmTimesheetApi:ChannelCodes");
Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using GarageGroup.Infra;
33
using GarageGroup.Infra.Bot.Builder;
4-
using Microsoft.Extensions.DependencyInjection;
54
using PrimeFuncPack;
65

76
namespace GarageGroup.Internal.Timesheet;
@@ -10,35 +9,31 @@ partial class Application
109
{
1110
internal static IBotBuilder UseAuthorizationFlow(this IBotBuilder botBuilder)
1211
=>
13-
botBuilder.UseDataverseAuthorization(
14-
ResolveBotAuthorizationOption,
15-
GetAzureUserApi,
16-
GetDataverseUserApi);
12+
Pipeline.Pipe(
13+
UseGraphHttpApi())
14+
.With(
15+
UseUserAuthorizationApi())
16+
.With(
17+
ResolveBotSignInOption)
18+
.MapSignInMiddleware(
19+
botBuilder);
1720

18-
private static IAzureUserApi GetAzureUserApi(IBotContext botContext)
21+
private static Dependency<IHttpApi> UseGraphHttpApi()
1922
=>
2023
PrimaryHandler.UseStandardSocketsHttpHandler()
21-
.UseLogging("AzureUserApi")
24+
.UseLogging("GraphApi")
2225
.UsePollyStandard()
23-
.UseAzureUserApi()
24-
.Resolve(botContext.ServiceProvider);
26+
.UseTokenCredentialStandard()
27+
.UseHttpApi();
2528

26-
private static IDataverseUserApi GetDataverseUserApi(IBotContext botContext)
27-
=>
28-
Dependency.From(
29-
ServiceProviderServiceExtensions.GetRequiredService<IDataverseApiClient>)
30-
.UseUserApi()
31-
.Resolve(
32-
botContext.ServiceProvider);
33-
34-
private static BotAuthorizationOption ResolveBotAuthorizationOption(this IBotContext context)
29+
private static BotSignInOption ResolveBotSignInOption(IServiceProvider serviceProvider)
3530
=>
3631
new(
37-
oAuthConnectionName: context.ServiceProvider.GetConfiguration()["OAuthConnectionName"].OrEmpty(),
32+
oAuthConnectionName: serviceProvider.GetConfiguration()["OAuthConnectionName"].OrEmpty(),
3833
enterText: """
39-
Войдите в свою учетную запись Garage Group:
40-
1. Перейдите по ссылке
41-
2. Авторизуйтесь под учетной записью Garage Group
42-
3. Скопируйте и отправьте полученный код в этот чат
34+
Sign in to your Garage Group account:
35+
1. Follow the link
36+
2. Sign in with your Garage Group account
37+
3. Copy and send the received code to this chat
4338
""");
4439
}

src/app/AzureFunc/Applicaton/BotFlow/Flow.BotInfo.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ private static IBotBuilder UseBotInfoFlow(this IBotBuilder botBuilder)
1414

1515
private static BotInfoData GetBotInfoData(IBotContext botContext)
1616
=>
17-
new(
18-
botContext.ServiceProvider.GetRequiredService<IConfiguration>().GetRequiredSection("Info").GetBotInfoData());
17+
new()
18+
{
19+
Values = botContext.ServiceProvider.GetRequiredService<IConfiguration>().GetRequiredSection("Info").GetBotInfoValue()
20+
};
1921

20-
private static FlatArray<KeyValuePair<string, string?>> GetBotInfoData(this IConfigurationSection section)
22+
private static FlatArray<KeyValuePair<string, string?>> GetBotInfoValue(this IConfigurationSection section)
2123
=>
2224
[
23-
new("Название", section["ApiName"]),
24-
new("Описание", section["Description"]),
25-
new("Версия сборки", section["ApiVersion"]),
26-
new("Время сборки", section.GetValue<DateTimeOffset?>("BuildDateTime").ToRussianStandardTimeZoneString())
25+
new("Name", section["ApiName"]),
26+
new("Description", section["Description"]),
27+
new("Version", section["ApiVersion"]),
28+
new("Build time", section.GetValue<DateTimeOffset?>("BuildDateTime").ToRussianStandardTimeZoneString())
2729
];
2830
}

src/app/AzureFunc/Applicaton/BotFlow/Flow.BotMenu.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ private static BotMenuData CreateMenuData()
1515
text: "Меню бота",
1616
commands:
1717
[
18-
new(Guid.Parse("31f7730f-5d18-468c-b540-1cd03e27c268"), TimesheetCreateCommand, "Списать время"),
19-
new(Guid.Parse("a5622d66-5b63-4d3b-a0c6-c5123ac8e538"), DateTimesheetGetCommand, "Показать мои списания времени"),
20-
new(Guid.Parse("49919c45-ef85-4fc9-a21d-8b5683303360"), BotInfoCommand, "О боте")
18+
new(Guid.Parse("31f7730f-5d18-468c-b540-1cd03e27c268"), TimesheetCreateCommand, "Create timesheet"),
19+
new(Guid.Parse("a5622d66-5b63-4d3b-a0c6-c5123ac8e538"), DateTimesheetGetCommand, "Show timesheets"),
20+
new(Guid.Parse("49919c45-ef85-4fc9-a21d-8b5683303360"), BotInfoCommand, "Information about the bot")
2121
]);
2222
}

src/app/AzureFunc/Applicaton/BotFlow/Flow.BotStop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ partial class Application
66
{
77
private static IBotBuilder UseBotStopFlow(this IBotBuilder botBuilder)
88
=>
9-
botBuilder.UseBotStop(StopCommand, static () => new(successText: "Операция остановлена"));
9+
botBuilder.UseBotStop(StopCommand, static () => new(successText: "The operation has been stopped"));
1010
}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using GarageGroup.Infra.Bot.Builder;
23

34
namespace GarageGroup.Internal.Timesheet;
@@ -6,5 +7,14 @@ partial class Application
67
{
78
private static IBotBuilder UseLogoutFlow(this IBotBuilder botBuilder)
89
=>
9-
botBuilder.UseLogout(LogoutCommand);
10+
Pipeline.Pipe(
11+
UseUserAuthorizationApi())
12+
.With(
13+
CreateBotSignOutOption)
14+
.MapSignOutCommand(
15+
botBuilder, LogoutCommand);
16+
17+
private static BotSignOutOption CreateBotSignOutOption()
18+
=>
19+
new();
1020
}

src/app/AzureFunc/Applicaton/BotFlow/Flow.TimesheetCreate.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ private static IBotBuilder UseTimesheetCreateFlow(this IBotBuilder botBuilder)
1313
UseCrmTimesheetApi())
1414
.With(
1515
ResolveTimesheetCreateFlowOptionOrThrow<TimesheetCreateFlowOption>)
16-
.MapTimesheetCreateFlow(botBuilder, TimesheetCreateCommand);
16+
.MapTimesheetCreateFlow(
17+
botBuilder, TimesheetCreateCommand);
1718
}

src/app/AzureFunc/AzureFunc.csproj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@
2828
<ItemGroup>
2929
<PackageReference Include="GarageGroup.Infra.Azure.DurableTask" Version="0.7.1" />
3030
<PackageReference Include="GarageGroup.Infra.Azure.Hosting" Version="0.10.0" />
31-
<PackageReference Include="GarageGroup.Infra.Azure.Services.AzureUser.Api" Version="0.1.1" />
32-
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Authorization.Dataverse" Version="0.4.0" />
33-
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Command.Info" Version="0.2.0" />
34-
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Command.Menu" Version="0.2.0" />
35-
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Command.Stop" Version="0.2.0" />
36-
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Integration.Handler" Version="0.4.0" />
37-
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Integration.Storage.CosmosDb" Version="0.5.0" />
31+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Authorization.Azure.Api.Dataverse" Version="0.0.1" />
32+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Authorization.Azure.Middleware" Version="0.0.1" />
33+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Command.Info" Version="0.3.0" />
34+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Command.Menu" Version="0.3.0" />
35+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Command.Stop" Version="0.3.0" />
36+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Integration.Handler" Version="0.5.0" />
37+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.Integration.Storage.CosmosDb" Version="0.6.0" />
38+
<PackageReference Include="GarageGroup.Infra.Bot.Builder.ProactiveMessage.Handler" Version="0.4.0" />
3839
<PackageReference Include="GarageGroup.Infra.Dataverse.Api" Version="3.16.1" />
39-
<PackageReference Include="GarageGroup.Infra.Dataverse.DataverseUser.Api" Version="1.3.0" />
4040
<PackageReference Include="GarageGroup.Infra.HealthCheck.Handler" Version="0.3.0" />
41+
<PackageReference Include="GarageGroup.Infra.Http.Api" Version="0.1.0" />
4142
<PackageReference Include="GarageGroup.Infra.Http.Polly" Version="2.0.0" />
4243
<PackageReference Include="GarageGroup.Infra.Sql.Api" Version="2.6.0" />
4344
<PackageReference Include="GarageGroup.Infra.Sql.Api.Provider.Dataverse" Version="0.1.0" />

src/app/AzureFunc/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Info": {
33
"ApiName": "Garage Timesheet Bot",
4-
"Description": "Бот учёта рабочего времени Garage Group",
4+
"Description": "Garage Group time tracking bot",
55
"ApiVersion": "",
66
"BuildDateTime": ""
77
},

0 commit comments

Comments
 (0)