Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Coscine
backend
apis
Notification
Commits
9ed2bb94
Commit
9ed2bb94
authored
Nov 09, 2020
by
Marcel Nellesen
Browse files
Merge branch 'Sprint/2020-20' into 'master'
Sprint/2020 20 See merge request coscine/api/notification!8
parents
38e7c735
9a5a463f
Changes
7
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
src/NotificationBus/App.config
View file @
9ed2bb94
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configSections
>
<!--
For
more
information
on
Entity
Framework
configuration
,
visit
http
://
go
.
microsoft
.
com
/
fwlink
/?
LinkID
=
237468
-->
<
section
name
=
"entityFramework"
type
=
"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
<!--
For
more
information
on
Entity
Framework
configuration
,
visit
http
://
go
.
microsoft
.
com
/
fwlink
/?
LinkID
=
237468
-->
<
section
name
=
"entityFramework"
type
=
"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
</
configSections
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.6.1"
/>
...
...
@@ -145,7 +145,7 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database"
publicKeyToken
=
"767d77427707b70a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
2.2
.0"
newVersion
=
"1.2
2.2
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
6.0
.0"
newVersion
=
"1.2
6.0
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Microsoft.Extensions.FileProviders.Abstractions"
publicKeyToken
=
"adb9793829ddae60"
culture
=
"neutral"
/>
...
...
@@ -175,6 +175,14 @@
<
assemblyIdentity
name
=
"Microsoft.AspNetCore.StaticFiles"
publicKeyToken
=
"adb9793829ddae60"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-2.2.0.0"
newVersion
=
"2.2.0.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"linq2db"
publicKeyToken
=
"e41013125f9e410a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-3.1.1.0"
newVersion
=
"3.1.1.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database.T4"
publicKeyToken
=
"84b4c404a0696261"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.26.0.0"
newVersion
=
"1.26.0.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
</
configuration
>
\ No newline at end of file
src/NotificationBus/Controller/NotificationBusController.cs
View file @
9ed2bb94
using
Coscine.ApiCommons
;
using
Coscine.ApiCommons.Factories
;
using
Coscine.Configuration
;
using
Coscine.Configuration
;
using
Coscine.Database.DataModel
;
using
Coscine.Database.Models
;
using
Coscine.NotificationChannelBase
;
using
Coscine.NotificationConfiguration
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json.Linq
;
using
Stubble.Core.Builders
;
using
Stubble.Core.Loaders
;
using
System
;
using
System.Collections.Generic
;
using
System.Reflection
;
...
...
@@ -47,15 +45,14 @@ namespace Coscine.Api.NotificationBus.Controllers
}
[
HttpPost
(
"[controller]/sendAsync"
)]
public
IActionResult
SendAsync
([
FromBody
]
NotificationParameterObject
notificationParameterObject
)
public
async
Task
<
IActionResult
>
SendAsync
([
FromBody
]
NotificationParameterObject
notificationParameterObject
)
{
SendNotifications
(
notificationParameterObject
);
await
SendNotifications
(
notificationParameterObject
);
return
Ok
();
}
private
async
Task
SendNotifications
(
NotificationParameterObject
notificationParameterObject
)
{
List
<
User
>
users
=
GetUsers
(
notificationParameterObject
.
UserIds
);
Project
project
=
GetProject
(
notificationParameterObject
.
ProjectId
);
var
action
=
notificationParameterObject
.
Action
;
ActionObject
actionObject
=
_notificationConfiguration
.
GetAction
(
action
);
...
...
@@ -84,7 +81,7 @@ namespace Coscine.Api.NotificationBus.Controllers
}
// for every available user
foreach
(
User
user
in
u
sers
)
foreach
(
User
user
in
notificationParameterObject
.
U
sers
)
{
JObject
messageData
=
FillTemplate
(
channelName
,
actionObject
,
notificationParameterObject
.
Args
,
user
,
project
);
...
...
@@ -114,7 +111,11 @@ namespace Coscine.Api.NotificationBus.Controllers
}
var
template
=
(
JObject
)(
action
.
Template
[
channelName
][
language
]);
var
stubble
=
new
StubbleBuilder
().
Build
();
var
stubble
=
new
StubbleBuilder
()
.
Configure
(
settings
=>
{
settings
.
SetPartialTemplateLoader
(
new
DictionaryLoader
(
_notificationConfiguration
.
GetPartialsForChannel
(
channelName
,
language
)));
}).
Build
();
var
dict
=
new
Dictionary
<
string
,
object
>();
if
(
requestArgs
[
"placeholder"
]
!=
null
)
...
...
@@ -130,7 +131,6 @@ namespace Coscine.Api.NotificationBus.Controllers
}
return
template
;
}
private
List
<
User
>
GetUsers
(
List
<
string
>
userIds
)
...
...
src/NotificationBus/NotificationBus.csproj
View file @
9ed2bb94
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"15.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"..\packages\EntityFramework.6.4.4\build\EntityFramework.props"
Condition=
"Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')"
/>
<Import
Project=
"..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.props"
Condition=
"Exists('..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.props')"
/>
<Import
Project=
"..\packages\Microsoft.Extensions.ApiDescription.Server.3.0.0\build\Microsoft.Extensions.ApiDescription.Server.props"
Condition=
"Exists('..\packages\Microsoft.Extensions.ApiDescription.Server.3.0.0\build\Microsoft.Extensions.ApiDescription.Server.props')"
/>
<Import
Project=
"..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props"
Condition=
"Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')"
/>
...
...
@@ -48,35 +49,38 @@
<Reference
Include=
"Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Consul.0.7.2.6\lib\net45\Consul.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.ApiCommons, Version=1.
9
.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ApiCommons.1.
9
.0\lib\net461\Coscine.ApiCommons.dll
</HintPath>
<Reference
Include=
"Coscine.ApiCommons, Version=1.
10
.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ApiCommons.1.
10
.0\lib\net461\Coscine.ApiCommons.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Database, Version=1.22.2.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.22.2\lib\net461\Coscine.Database.dll
</HintPath>
<Reference
Include=
"Coscine.Database, Version=1.26.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.26.0\lib\net461\Coscine.Database.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Database.T4, Version=1.26.0.0, Culture=neutral, PublicKeyToken=84b4c404a0696261, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.26.0\lib\net461\Coscine.Database.T4.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e1ed402bc3f6525e, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Logging.1.2.0\lib\net461\Coscine.Logging.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.NotificationChannelBase, Version=1.1.
0
.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.NotificationChannelBase.1.1.
0
\lib\net461\Coscine.NotificationChannelBase.dll
</HintPath>
<Reference
Include=
"Coscine.NotificationChannelBase, Version=1.1.
1
.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.NotificationChannelBase.1.1.
1
\lib\net461\Coscine.NotificationChannelBase.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.NotificationConfiguration, Version=1.
3
.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.NotificationConfiguration.1.
3
.0\lib\net461\Coscine.NotificationConfiguration.dll
</HintPath>
<Reference
Include=
"Coscine.NotificationConfiguration, Version=1.
4
.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.NotificationConfiguration.1.
4
.0\lib\net461\Coscine.NotificationConfiguration.dll
</HintPath>
</Reference>
<Reference
Include=
"Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll
</HintPath>
</Reference>
<Reference
Include=
"EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
>
<HintPath>
..\packages\EntityFramework.6.
2.0
\lib\net45\EntityFramework.dll
</HintPath>
<HintPath>
..\packages\EntityFramework.6.
4.4
\lib\net45\EntityFramework.dll
</HintPath>
</Reference>
<Reference
Include=
"EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
>
<HintPath>
..\packages\EntityFramework.6.
2.0
\lib\net45\EntityFramework.SqlServer.dll
</HintPath>
<HintPath>
..\packages\EntityFramework.6.
4.4
\lib\net45\EntityFramework.SqlServer.dll
</HintPath>
</Reference>
<Reference
Include=
"linq2db, Version=
2.6.4
.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\linq2db.
2.6.4
\lib\net46\linq2db.dll
</HintPath>
<Reference
Include=
"linq2db, Version=
3.1.1
.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\linq2db.
3.1.1
\lib\net46\linq2db.dll
</HintPath>
</Reference>
<Reference
Include=
"LinqKit, Version=1.1.17.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL"
>
<HintPath>
..\packages\LinqKit.1.1.17\lib\net45\LinqKit.dll
</HintPath>
...
...
@@ -552,9 +556,12 @@
<Error
Condition=
"!Exists('..\packages\Microsoft.Extensions.ApiDescription.Server.3.0.0\build\Microsoft.Extensions.ApiDescription.Server.targets')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.ApiDescription.Server.3.0.0\build\Microsoft.Extensions.ApiDescription.Server.targets'))"
/>
<Error
Condition=
"!Exists('..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.props')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.props'))"
/>
<Error
Condition=
"!Exists('..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.targets')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.targets'))"
/>
<Error
Condition=
"!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))"
/>
<Error
Condition=
"!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))"
/>
</Target>
<Import
Project=
"..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.targets"
Condition=
"Exists('..\packages\Microsoft.AspNetCore.Mvc.Razor.Extensions.2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.targets')"
/>
<Import
Project=
"..\packages\Fody.6.0.0\build\Fody.targets"
Condition=
"Exists('..\packages\Fody.6.0.0\build\Fody.targets')"
/>
<Import
Project=
"..\packages\Microsoft.Extensions.ApiDescription.Server.3.0.0\build\Microsoft.Extensions.ApiDescription.Server.targets"
Condition=
"Exists('..\packages\Microsoft.Extensions.ApiDescription.Server.3.0.0\build\Microsoft.Extensions.ApiDescription.Server.targets')"
/>
<Import
Project=
"..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.targets"
Condition=
"Exists('..\packages\NSwag.AspNetCore.13.6.2\build\NSwag.AspNetCore.targets')"
/>
<Import
Project=
"..\packages\EntityFramework.6.4.4\build\EntityFramework.targets"
Condition=
"Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')"
/>
</Project>
\ No newline at end of file
src/NotificationBus/NotificationParameterObject.cs
View file @
9ed2bb94
using
Newtonsoft.Json.Linq
;
using
System
;
using
Coscine.Database.DataModel
;
using
Newtonsoft.Json.Linq
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Coscine.Api.NotificationBus
{
public
class
NotificationParameterObject
{
public
List
<
string
>
User
Id
s
{
get
;
set
;
}
public
List
<
User
>
Users
{
get
;
set
;
}
public
string
Action
{
get
;
set
;
}
...
...
@@ -24,10 +21,10 @@ namespace Coscine.Api.NotificationBus
}
public
NotificationParameterObject
(
string
action
,
List
<
string
>
user
Id
s
,
string
projectId
,
JObject
args
,
string
href
)
public
NotificationParameterObject
(
string
action
,
List
<
User
>
users
,
string
projectId
,
JObject
args
,
string
href
)
{
Action
=
action
;
User
Id
s
=
user
Id
s
;
Users
=
users
;
ProjectId
=
projectId
;
Args
=
args
;
Href
=
href
;
...
...
src/NotificationBus/Program.cs
View file @
9ed2bb94
using
Coscine.ApiCommons
;
using
Coscine.Configuration
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Coscine.Api.NotificationBus
{
...
...
src/NotificationBus/Startup.cs
View file @
9ed2bb94
using
Coscine.ApiCommons
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Coscine.Api.NotificationBus
{
...
...
src/NotificationBus/packages.config
View file @
9ed2bb94
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Consul"
version
=
"0.7.2.6"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.ApiCommons"
version
=
"1.
9
.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.ApiCommons"
version
=
"1.
10
.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.Configuration"
version
=
"1.5.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.2
2.2
"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.2
6.0
"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.Logging"
version
=
"1.2.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.NotificationChannelBase"
version
=
"1.1.
0
"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.NotificationConfiguration"
version
=
"1.
3
.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.NotificationChannelBase"
version
=
"1.1.
1
"
targetFramework
=
"net461"
/>
<
package
id
=
"Coscine.NotificationConfiguration"
version
=
"1.
4
.0"
targetFramework
=
"net461"
/>
<
package
id
=
"Costura.Fody"
version
=
"4.1.0"
targetFramework
=
"net461"
/>
<
package
id
=
"EntityFramework"
version
=
"6.
2.0
"
targetFramework
=
"net461"
/>
<
package
id
=
"EntityFramework"
version
=
"6.
4.4
"
targetFramework
=
"net461"
/>
<
package
id
=
"Fody"
version
=
"6.0.0"
targetFramework
=
"net461"
developmentDependency
=
"true"
/>
<
package
id
=
"linq2db"
version
=
"
2.6.4
"
targetFramework
=
"net461"
/>
<
package
id
=
"linq2db"
version
=
"
3.1.1
"
targetFramework
=
"net461"
/>
<
package
id
=
"linq2db.SqlServer"
version
=
"2.6.4"
targetFramework
=
"net461"
/>
<
package
id
=
"linq2db.t4models"
version
=
"2.6.4"
targetFramework
=
"net461"
/>
<
package
id
=
"LinqKit"
version
=
"1.1.17"
targetFramework
=
"net461"
/>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment