Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Coscine
backend
apis
Project
Commits
c54b4453
Commit
c54b4453
authored
May 28, 2021
by
Petar Hristov
💬
Browse files
Fix: Naming and Json Property of Invitation Object (coscine/issues#1530)
parent
db7d88e5
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Project/Controllers/ProjectController.cs
View file @
c54b4453
...
...
@@ -620,13 +620,13 @@ namespace Coscine.Api.Project.Controllers
/// <param name="sendInvitationObject">Informations for sending an invitation</param>
/// <returns>NoContent</returns>
[
HttpPost
(
"[controller]/invitation"
)]
public
IActionResult
SendInvitation
(
SendInvitationObject
sendInvitationObject
)
public
IActionResult
SendInvitation
(
[
FromBody
]
SendInvitationObject
sendInvitationObject
)
{
var
user
=
_authenticator
.
GetUser
();
if
(!
IsValidEmail
(
sendInvitationObject
.
M
ail
))
if
(!
IsValidEmail
(
sendInvitationObject
.
Em
ail
))
{
return
BadRequest
(
$@"The email ""
{
sendInvitationObject
.
M
ail
}
"" is invalid."
);
return
BadRequest
(
$@"The email ""
{
sendInvitationObject
.
Em
ail
}
"" is invalid."
);
}
var
project
=
_projectModel
.
GetById
(
sendInvitationObject
.
Project
);
...
...
@@ -648,7 +648,7 @@ namespace Coscine.Api.Project.Controllers
var
invitations
=
_invitationModel
.
GetAllWhere
(
x
=>
x
.
Project
==
sendInvitationObject
.
Project
&&
x
.
InviteeEmail
==
sendInvitationObject
.
M
ail
&&
x
.
InviteeEmail
==
sendInvitationObject
.
Em
ail
&&
x
.
Expiration
>
DateTime
.
UtcNow
);
...
...
@@ -657,7 +657,7 @@ namespace Coscine.Api.Project.Controllers
return
BadRequest
(
"This invitee already has a valid invitation to this project."
);
}
var
token
=
_invitationModel
.
CreateInvitation
(
sendInvitationObject
.
Project
,
user
.
Id
,
sendInvitationObject
.
Role
,
sendInvitationObject
.
M
ail
);
var
token
=
_invitationModel
.
CreateInvitation
(
sendInvitationObject
.
Project
,
user
.
Id
,
sendInvitationObject
.
Role
,
sendInvitationObject
.
Em
ail
);
var
body
=
new
JObject
{
...
...
@@ -670,7 +670,7 @@ namespace Coscine.Api.Project.Controllers
}
};
NotificationBusUtil
.
Send
(
Program
.
Configuration
,
"user_invitation"
,
NotificationBusUtil
.
GetUserList
(
new
User
{
EmailAddress
=
sendInvitationObject
.
M
ail
}),
sendInvitationObject
.
Project
.
ToString
(),
body
);
NotificationBusUtil
.
Send
(
Program
.
Configuration
,
"user_invitation"
,
NotificationBusUtil
.
GetUserList
(
new
User
{
EmailAddress
=
sendInvitationObject
.
Em
ail
}),
sendInvitationObject
.
Project
.
ToString
(),
body
);
return
NoContent
();
}
...
...
src/Project/ParameterObjects/SendInvitationObject.cs
View file @
c54b4453
using
System
;
using
Newtonsoft.Json
;
namespace
Coscine.Api.Project.ParameterObjects
{
...
...
@@ -10,14 +11,17 @@ namespace Coscine.Api.Project.ParameterObjects
/// <summary>
/// Id of the project
/// </summary>
[
JsonProperty
(
"projectId"
)]
public
Guid
Project
{
get
;
set
;
}
/// <summary>
/// Id of the target role
/// </summary>
[
JsonProperty
(
"role"
)]
public
Guid
Role
{
get
;
set
;
}
/// <summary>
/// Email of the target user
/// </summary>
public
string
Mail
{
get
;
set
;
}
[
JsonProperty
(
"email"
)]
public
string
Email
{
get
;
set
;
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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