Skip to content

Commit 1c9eab2

Browse files
authored
Merge pull request #70 from GarageGroup/feature/use-tg-web-app-only
Use v4: Telegram Web App Only
2 parents bed596b + b6b1b03 commit 1c9eab2

File tree

201 files changed

+1274
-6762
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+1274
-6762
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: dotnet test --no-restore -c Release
3535

3636
- name: Publish AzureFunc
37-
run: dotnet publish ./src/*/*/AzureFunc.csproj -c Release --output ./publish
37+
run: dotnet publish ./src/*/AzureFunc.csproj -c Release --output ./publish
3838

3939
- name: Get version
4040
id: get_version

Internal.Timesheet.Bot.sln

Lines changed: 5 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -3,164 +3,22 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{E87022B0-BD92-4A69-9067-C0F63AE065CC}"
7-
EndProject
8-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "endpoint", "endpoint", "{7D9CDEDB-482B-476A-BB7F-662F7F838FE1}"
9-
EndProject
10-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Timesheet.Show", "Timesheet.Show", "{A983929D-6468-4F3B-B70C-A550AD9F6426}"
11-
EndProject
12-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureFunc", "src\app\AzureFunc\AzureFunc.csproj", "{997B1FC9-5AAD-4295-8D20-77F0FD1FBA29}"
13-
EndProject
14-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "service", "service", "{43D27A23-A5EE-4FD5-A7FE-40F567073A0A}"
15-
EndProject
16-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{77EC7666-BD6E-4D74-BAE8-38E75952CBD5}"
17-
EndProject
18-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entity", "src\service\Shared\Entity\Entity.csproj", "{A7C4830A-FF6F-4AE7-9313-46DE45FF8251}"
19-
EndProject
20-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CrmProject", "CrmProject", "{8675B278-D3FB-4674-9264-05BEFAA058B3}"
21-
EndProject
22-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contract", "src\service\CrmProject\Contract\Contract.csproj", "{EE31539A-7C97-4AEE-8D17-C8A4BDA84B49}"
23-
EndProject
24-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "src\service\CrmProject\Api\Api.csproj", "{20FF6D5E-2D6D-4885-A08D-F9486A2877D2}"
25-
EndProject
26-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "src\service\CrmProject\Test\Test.csproj", "{790BFA4B-789D-4F24-BC85-99D3074AA75F}"
27-
EndProject
28-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CrmTimesheet", "CrmTimesheet", "{68A33764-3D85-4805-85DF-AE31D9C67D74}"
29-
EndProject
30-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contract", "src\service\CrmTimesheet\Contract\Contract.csproj", "{2BF1F379-231A-4C17-9A9D-42090D90D584}"
31-
EndProject
32-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "src\service\CrmTimesheet\Api\Api.csproj", "{7A8288BA-A475-4A0A-9257-D47E2EF5E358}"
33-
EndProject
34-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "src\service\CrmTimesheet\Test\Test.csproj", "{29D2A481-5ADB-4DE2-95BE-9FC9DB89133D}"
35-
EndProject
36-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contract", "src\endpoint\Timesheet.Show\Contract\Contract.csproj", "{EBB1BC2F-4502-4D24-83CD-88EEA9F0B029}"
37-
EndProject
38-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow", "src\endpoint\Timesheet.Show\Flow\Flow.csproj", "{F50E9A59-6F66-42DA-A64B-4DB7AA2FA8B5}"
39-
EndProject
40-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Timesheet.Create", "Timesheet.Create", "{CDACACAC-FDA8-49B4-951A-B0C61432AA93}"
41-
EndProject
42-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contract", "src\endpoint\Timesheet.Create\Contract\Contract.csproj", "{A0FC383E-501A-467A-8CA5-3C4FEC444EF8}"
43-
EndProject
44-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow", "src\endpoint\Timesheet.Create\Flow\Flow.csproj", "{8D15DDC7-96E0-405A-91A7-A4BE9764A22E}"
45-
EndProject
46-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Timesheet.Delete", "Timesheet.Delete", "{AB07E339-90E9-47E4-BFFF-FDE066DC2149}"
47-
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contract", "src\endpoint\Timesheet.Delete\Contract\Contract.csproj", "{65A7520C-6BAA-43F9-8A0E-27D0D78A1308}"
49-
EndProject
50-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow", "src\endpoint\Timesheet.Delete\Flow\Flow.csproj", "{6EABE83A-C860-4F4A-ABE7-806F6782421E}"
51-
EndProject
52-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Claims.Provide", "Claims.Provide", "{692D3D9A-9638-4451-9EED-DCBEB995FC28}"
53-
EndProject
54-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contract", "src\endpoint\Claims.Provide\Contract\Contract.csproj", "{C21B9DA9-0F95-4448-8753-6A7EF0DA2E3D}"
55-
EndProject
56-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Endpoint", "src\endpoint\Claims.Provide\Endpoint\Endpoint.csproj", "{0E9BE82C-27C3-47B6-B4C4-B0AC5F8610DC}"
57-
EndProject
58-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "src\endpoint\Claims.Provide\Test\Test.csproj", "{C6B6FD44-FEB4-483E-BDE4-7B2B26D5C702}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureFunc", "src\AzureFunc\AzureFunc.csproj", "{3790B3D1-CF02-4C43-AD00-5CDED94FE420}"
597
EndProject
608
Global
619
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6210
Debug|Any CPU = Debug|Any CPU
6311
Release|Any CPU = Release|Any CPU
6412
EndGlobalSection
6513
GlobalSection(ProjectConfigurationPlatforms) = postSolution
66-
{997B1FC9-5AAD-4295-8D20-77F0FD1FBA29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67-
{997B1FC9-5AAD-4295-8D20-77F0FD1FBA29}.Debug|Any CPU.Build.0 = Debug|Any CPU
68-
{997B1FC9-5AAD-4295-8D20-77F0FD1FBA29}.Release|Any CPU.ActiveCfg = Release|Any CPU
69-
{997B1FC9-5AAD-4295-8D20-77F0FD1FBA29}.Release|Any CPU.Build.0 = Release|Any CPU
70-
{A7C4830A-FF6F-4AE7-9313-46DE45FF8251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71-
{A7C4830A-FF6F-4AE7-9313-46DE45FF8251}.Debug|Any CPU.Build.0 = Debug|Any CPU
72-
{A7C4830A-FF6F-4AE7-9313-46DE45FF8251}.Release|Any CPU.ActiveCfg = Release|Any CPU
73-
{A7C4830A-FF6F-4AE7-9313-46DE45FF8251}.Release|Any CPU.Build.0 = Release|Any CPU
74-
{EE31539A-7C97-4AEE-8D17-C8A4BDA84B49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75-
{EE31539A-7C97-4AEE-8D17-C8A4BDA84B49}.Debug|Any CPU.Build.0 = Debug|Any CPU
76-
{EE31539A-7C97-4AEE-8D17-C8A4BDA84B49}.Release|Any CPU.ActiveCfg = Release|Any CPU
77-
{EE31539A-7C97-4AEE-8D17-C8A4BDA84B49}.Release|Any CPU.Build.0 = Release|Any CPU
78-
{20FF6D5E-2D6D-4885-A08D-F9486A2877D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79-
{20FF6D5E-2D6D-4885-A08D-F9486A2877D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
80-
{20FF6D5E-2D6D-4885-A08D-F9486A2877D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
81-
{20FF6D5E-2D6D-4885-A08D-F9486A2877D2}.Release|Any CPU.Build.0 = Release|Any CPU
82-
{790BFA4B-789D-4F24-BC85-99D3074AA75F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83-
{790BFA4B-789D-4F24-BC85-99D3074AA75F}.Debug|Any CPU.Build.0 = Debug|Any CPU
84-
{790BFA4B-789D-4F24-BC85-99D3074AA75F}.Release|Any CPU.ActiveCfg = Release|Any CPU
85-
{790BFA4B-789D-4F24-BC85-99D3074AA75F}.Release|Any CPU.Build.0 = Release|Any CPU
86-
{2BF1F379-231A-4C17-9A9D-42090D90D584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87-
{2BF1F379-231A-4C17-9A9D-42090D90D584}.Debug|Any CPU.Build.0 = Debug|Any CPU
88-
{2BF1F379-231A-4C17-9A9D-42090D90D584}.Release|Any CPU.ActiveCfg = Release|Any CPU
89-
{2BF1F379-231A-4C17-9A9D-42090D90D584}.Release|Any CPU.Build.0 = Release|Any CPU
90-
{7A8288BA-A475-4A0A-9257-D47E2EF5E358}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
91-
{7A8288BA-A475-4A0A-9257-D47E2EF5E358}.Debug|Any CPU.Build.0 = Debug|Any CPU
92-
{7A8288BA-A475-4A0A-9257-D47E2EF5E358}.Release|Any CPU.ActiveCfg = Release|Any CPU
93-
{7A8288BA-A475-4A0A-9257-D47E2EF5E358}.Release|Any CPU.Build.0 = Release|Any CPU
94-
{29D2A481-5ADB-4DE2-95BE-9FC9DB89133D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95-
{29D2A481-5ADB-4DE2-95BE-9FC9DB89133D}.Debug|Any CPU.Build.0 = Debug|Any CPU
96-
{29D2A481-5ADB-4DE2-95BE-9FC9DB89133D}.Release|Any CPU.ActiveCfg = Release|Any CPU
97-
{29D2A481-5ADB-4DE2-95BE-9FC9DB89133D}.Release|Any CPU.Build.0 = Release|Any CPU
98-
{EBB1BC2F-4502-4D24-83CD-88EEA9F0B029}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99-
{EBB1BC2F-4502-4D24-83CD-88EEA9F0B029}.Debug|Any CPU.Build.0 = Debug|Any CPU
100-
{EBB1BC2F-4502-4D24-83CD-88EEA9F0B029}.Release|Any CPU.ActiveCfg = Release|Any CPU
101-
{EBB1BC2F-4502-4D24-83CD-88EEA9F0B029}.Release|Any CPU.Build.0 = Release|Any CPU
102-
{F50E9A59-6F66-42DA-A64B-4DB7AA2FA8B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
103-
{F50E9A59-6F66-42DA-A64B-4DB7AA2FA8B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
104-
{F50E9A59-6F66-42DA-A64B-4DB7AA2FA8B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
105-
{F50E9A59-6F66-42DA-A64B-4DB7AA2FA8B5}.Release|Any CPU.Build.0 = Release|Any CPU
106-
{A0FC383E-501A-467A-8CA5-3C4FEC444EF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
107-
{A0FC383E-501A-467A-8CA5-3C4FEC444EF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
108-
{A0FC383E-501A-467A-8CA5-3C4FEC444EF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
109-
{A0FC383E-501A-467A-8CA5-3C4FEC444EF8}.Release|Any CPU.Build.0 = Release|Any CPU
110-
{8D15DDC7-96E0-405A-91A7-A4BE9764A22E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
111-
{8D15DDC7-96E0-405A-91A7-A4BE9764A22E}.Debug|Any CPU.Build.0 = Debug|Any CPU
112-
{8D15DDC7-96E0-405A-91A7-A4BE9764A22E}.Release|Any CPU.ActiveCfg = Release|Any CPU
113-
{8D15DDC7-96E0-405A-91A7-A4BE9764A22E}.Release|Any CPU.Build.0 = Release|Any CPU
114-
{65A7520C-6BAA-43F9-8A0E-27D0D78A1308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
115-
{65A7520C-6BAA-43F9-8A0E-27D0D78A1308}.Debug|Any CPU.Build.0 = Debug|Any CPU
116-
{65A7520C-6BAA-43F9-8A0E-27D0D78A1308}.Release|Any CPU.ActiveCfg = Release|Any CPU
117-
{65A7520C-6BAA-43F9-8A0E-27D0D78A1308}.Release|Any CPU.Build.0 = Release|Any CPU
118-
{6EABE83A-C860-4F4A-ABE7-806F6782421E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
119-
{6EABE83A-C860-4F4A-ABE7-806F6782421E}.Debug|Any CPU.Build.0 = Debug|Any CPU
120-
{6EABE83A-C860-4F4A-ABE7-806F6782421E}.Release|Any CPU.ActiveCfg = Release|Any CPU
121-
{6EABE83A-C860-4F4A-ABE7-806F6782421E}.Release|Any CPU.Build.0 = Release|Any CPU
122-
{C21B9DA9-0F95-4448-8753-6A7EF0DA2E3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
123-
{C21B9DA9-0F95-4448-8753-6A7EF0DA2E3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
124-
{C21B9DA9-0F95-4448-8753-6A7EF0DA2E3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
125-
{C21B9DA9-0F95-4448-8753-6A7EF0DA2E3D}.Release|Any CPU.Build.0 = Release|Any CPU
126-
{0E9BE82C-27C3-47B6-B4C4-B0AC5F8610DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
127-
{0E9BE82C-27C3-47B6-B4C4-B0AC5F8610DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
128-
{0E9BE82C-27C3-47B6-B4C4-B0AC5F8610DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
129-
{0E9BE82C-27C3-47B6-B4C4-B0AC5F8610DC}.Release|Any CPU.Build.0 = Release|Any CPU
130-
{C6B6FD44-FEB4-483E-BDE4-7B2B26D5C702}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
131-
{C6B6FD44-FEB4-483E-BDE4-7B2B26D5C702}.Debug|Any CPU.Build.0 = Debug|Any CPU
132-
{C6B6FD44-FEB4-483E-BDE4-7B2B26D5C702}.Release|Any CPU.ActiveCfg = Release|Any CPU
133-
{C6B6FD44-FEB4-483E-BDE4-7B2B26D5C702}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{3790B3D1-CF02-4C43-AD00-5CDED94FE420}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3790B3D1-CF02-4C43-AD00-5CDED94FE420}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3790B3D1-CF02-4C43-AD00-5CDED94FE420}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{3790B3D1-CF02-4C43-AD00-5CDED94FE420}.Release|Any CPU.Build.0 = Release|Any CPU
13418
EndGlobalSection
13519
GlobalSection(SolutionProperties) = preSolution
13620
HideSolutionNode = FALSE
13721
EndGlobalSection
138-
GlobalSection(NestedProjects) = preSolution
139-
{A983929D-6468-4F3B-B70C-A550AD9F6426} = {7D9CDEDB-482B-476A-BB7F-662F7F838FE1}
140-
{997B1FC9-5AAD-4295-8D20-77F0FD1FBA29} = {E87022B0-BD92-4A69-9067-C0F63AE065CC}
141-
{77EC7666-BD6E-4D74-BAE8-38E75952CBD5} = {43D27A23-A5EE-4FD5-A7FE-40F567073A0A}
142-
{A7C4830A-FF6F-4AE7-9313-46DE45FF8251} = {77EC7666-BD6E-4D74-BAE8-38E75952CBD5}
143-
{8675B278-D3FB-4674-9264-05BEFAA058B3} = {43D27A23-A5EE-4FD5-A7FE-40F567073A0A}
144-
{EE31539A-7C97-4AEE-8D17-C8A4BDA84B49} = {8675B278-D3FB-4674-9264-05BEFAA058B3}
145-
{20FF6D5E-2D6D-4885-A08D-F9486A2877D2} = {8675B278-D3FB-4674-9264-05BEFAA058B3}
146-
{790BFA4B-789D-4F24-BC85-99D3074AA75F} = {8675B278-D3FB-4674-9264-05BEFAA058B3}
147-
{68A33764-3D85-4805-85DF-AE31D9C67D74} = {43D27A23-A5EE-4FD5-A7FE-40F567073A0A}
148-
{2BF1F379-231A-4C17-9A9D-42090D90D584} = {68A33764-3D85-4805-85DF-AE31D9C67D74}
149-
{7A8288BA-A475-4A0A-9257-D47E2EF5E358} = {68A33764-3D85-4805-85DF-AE31D9C67D74}
150-
{29D2A481-5ADB-4DE2-95BE-9FC9DB89133D} = {68A33764-3D85-4805-85DF-AE31D9C67D74}
151-
{EBB1BC2F-4502-4D24-83CD-88EEA9F0B029} = {A983929D-6468-4F3B-B70C-A550AD9F6426}
152-
{F50E9A59-6F66-42DA-A64B-4DB7AA2FA8B5} = {A983929D-6468-4F3B-B70C-A550AD9F6426}
153-
{CDACACAC-FDA8-49B4-951A-B0C61432AA93} = {7D9CDEDB-482B-476A-BB7F-662F7F838FE1}
154-
{A0FC383E-501A-467A-8CA5-3C4FEC444EF8} = {CDACACAC-FDA8-49B4-951A-B0C61432AA93}
155-
{8D15DDC7-96E0-405A-91A7-A4BE9764A22E} = {CDACACAC-FDA8-49B4-951A-B0C61432AA93}
156-
{AB07E339-90E9-47E4-BFFF-FDE066DC2149} = {7D9CDEDB-482B-476A-BB7F-662F7F838FE1}
157-
{65A7520C-6BAA-43F9-8A0E-27D0D78A1308} = {AB07E339-90E9-47E4-BFFF-FDE066DC2149}
158-
{6EABE83A-C860-4F4A-ABE7-806F6782421E} = {AB07E339-90E9-47E4-BFFF-FDE066DC2149}
159-
{692D3D9A-9638-4451-9EED-DCBEB995FC28} = {7D9CDEDB-482B-476A-BB7F-662F7F838FE1}
160-
{C21B9DA9-0F95-4448-8753-6A7EF0DA2E3D} = {692D3D9A-9638-4451-9EED-DCBEB995FC28}
161-
{0E9BE82C-27C3-47B6-B4C4-B0AC5F8610DC} = {692D3D9A-9638-4451-9EED-DCBEB995FC28}
162-
{C6B6FD44-FEB4-483E-BDE4-7B2B26D5C702} = {692D3D9A-9638-4451-9EED-DCBEB995FC28}
163-
EndGlobalSection
16422
GlobalSection(ExtensibilityGlobals) = postSolution
16523
SolutionGuid = {ABFD3626-C36B-4027-95E4-020B5A983788}
16624
EndGlobalSection

src/app/AzureFunc/Application/App.Bot.cs renamed to src/AzureFunc/Application/App.Bot.cs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using GarageGroup.Infra;
23
using GarageGroup.Infra.Telegram.Bot;
34
using Microsoft.Azure.Functions.Worker;
@@ -24,14 +25,32 @@ internal static Dependency<IBotWebHookHandler> UseBot()
2425
Dependency.From(
2526
ServiceProviderServiceExtensions.GetRequiredService<BotProvider>)
2627
.GetBotBuilder()
27-
.UseAuthorization()
28+
.Next(
29+
UseCultureMiddleware())
2830
.UseCommands()
29-
.WithTimesheetCreateCommand()
30-
.WithTimesheetShowCommand()
31-
.WithTimesheetDeleteCommand()
32-
.WithBotInfoCommand()
33-
.WithBotStopCommand()
34-
.WithLogoutCommand()
35-
.WithBotMenuCommand()
31+
.With(
32+
UseSignOutCommand())
33+
.With(
34+
"info", BotCommand.UseBotInfoCommand())
35+
.With(
36+
UseWelcomeCommand())
3637
.BuildWebHookHandler();
38+
39+
private static Dependency<IChatMiddleware> UseCultureMiddleware()
40+
=>
41+
Dependency.From(
42+
ServiceProviderServiceExtensions.GetRequiredService<IUserAuthorizationApi>)
43+
.UseCultureMiddleware();
44+
45+
private static Dependency<IChatCommand<SignOutCommandIn, Unit>> UseSignOutCommand()
46+
=>
47+
Dependency.From(
48+
ServiceProviderServiceExtensions.GetRequiredService<IUserAuthorizationApi>)
49+
.UseSignOutCommand();
50+
51+
private static Dependency<IChatCommand<WelcomeCommandIn, Unit>> UseWelcomeCommand()
52+
=>
53+
Dependency.From(
54+
ServiceProviderServiceExtensions.GetRequiredService<WelcomeOption>)
55+
.UseWelcomeCommand();
3756
}

src/app/AzureFunc/Application/App.Health.Check.cs renamed to src/AzureFunc/Application/App.Health.Check.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using GarageGroup.Infra;
1+
using System;
2+
using GarageGroup.Infra;
3+
using GarageGroup.Infra.Telegram.Bot;
24
using Microsoft.Extensions.DependencyInjection;
35
using PrimeFuncPack;
46

@@ -11,7 +13,10 @@ internal static Dependency<IHealthCheckHandler> UseHealthCheck()
1113
=>
1214
HealthCheck.UseServices(
1315
Dependency.From(ResolveBotApi).UseServiceHealthCheckApi("TelegramBotApi"),
14-
Dependency.From(ServiceProviderServiceExtensions.GetRequiredService<ISqlApi>).UseServiceHealthCheckApi("DataverseDb"),
1516
Dependency.From(ServiceProviderServiceExtensions.GetRequiredService<IDataverseApiClient>).UseServiceHealthCheckApi("DataverseApi"))
1617
.UseHealthCheckHandler();
18+
19+
private static IBotApi ResolveBotApi(IServiceProvider serviceProvider)
20+
=>
21+
serviceProvider.GetRequiredService<BotProvider>().BotApi;
1722
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace GarageGroup.Internal.Timesheet;
2+
3+
internal static partial class Application
4+
{
5+
private const string BotEntityName = "TelegramBotRequest";
6+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using GarageGroup.Infra;
3+
using GarageGroup.Infra.Telegram.Bot;
4+
using Microsoft.Azure.Functions.Worker;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Hosting;
8+
using PrimeFuncPack;
9+
10+
namespace GarageGroup.Internal.Timesheet;
11+
12+
partial class ApplicationHost
13+
{
14+
internal static IHostBuilder CreateBuilder()
15+
=>
16+
FunctionHost.CreateFunctionsWorkerBuilderStandard(
17+
useHostConfiguration: false,
18+
configure: Configure);
19+
20+
private static void Configure(IFunctionsWorkerApplicationBuilder builder)
21+
=>
22+
builder.Services
23+
.RegisterBotProvider()
24+
.RegisterDataverseApi()
25+
.RegisterUserAuthorizationApi()
26+
.RegisterWelcomeOption();
27+
28+
private static IServiceCollection RegisterBotProvider(this IServiceCollection services)
29+
=>
30+
PrimaryHandler.UseStandardSocketsHttpHandler()
31+
.UseLogging("BotApi")
32+
.UsePollyStandard()
33+
.ConfigureHttpHeader("Ocp-Apim-Subscription-Key", "TelegramBot:ApiKey")
34+
.UseHttpApi("TelegramBot")
35+
.UseTelegramBotApi()
36+
.With<IBotStorage>(InMemoryBotStorage.Instance)
37+
.UseBotProvider("Bot")
38+
.ToRegistrar(services)
39+
.RegisterSingleton();
40+
41+
private static IServiceCollection RegisterDataverseApi(this IServiceCollection services)
42+
=>
43+
PrimaryHandler.UseStandardSocketsHttpHandler()
44+
.UseLogging("DataverseApi")
45+
.UseTokenCredentialStandard()
46+
.UsePollyStandard()
47+
.UseDataverseApiClient("Dataverse")
48+
.ToRegistrar(services)
49+
.RegisterScoped();
50+
51+
private static IServiceCollection RegisterUserAuthorizationApi(this IServiceCollection services)
52+
=>
53+
PrimaryHandler.UseStandardSocketsHttpHandler()
54+
.UseLogging("AzureAuthorizationApi")
55+
.UsePollyStandard()
56+
.UseHttpApi()
57+
.With(ServiceProviderServiceExtensions.GetRequiredService<IDataverseApiClient>)
58+
.UseUserAuthorizationApi()
59+
.ToRegistrar(services)
60+
.RegisterScoped();
61+
62+
private static IServiceCollection RegisterWelcomeOption(this IServiceCollection services)
63+
=>
64+
services.AddSingleton(ResolveWelcomeOption);
65+
66+
private static WelcomeOption ResolveWelcomeOption(IServiceProvider serviceProvider)
67+
{
68+
var section = serviceProvider.GetRequiredService<IConfiguration>().GetRequiredSection("Welcome");
69+
70+
return new(
71+
imageUrl: section["ImageUrl"].OrEmpty())
72+
{
73+
Emojis = section.GetSection("Emojis").Get<string[]>()
74+
};
75+
}
76+
}

0 commit comments

Comments
 (0)