Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
boco-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106_2022_02
boco-backend
Commits
d55672b7
Commit
d55672b7
authored
3 years ago
by
Haakon Tideman Kanter
Browse files
Options
Downloads
Patches
Plain Diff
javadoc version 0.2
parent
f2a3d8d9
No related branches found
No related tags found
1 merge request
!88
Controller docpdate
Pipeline
#182056
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/ntnu/idatt2106/controller/UserCommunityController.java
+7
-6
7 additions, 6 deletions
...no/ntnu/idatt2106/controller/UserCommunityController.java
with
7 additions
and
6 deletions
src/main/java/no/ntnu/idatt2106/controller/UserCommunityController.java
+
7
−
6
View file @
d55672b7
...
...
@@ -40,9 +40,9 @@ public class UserCommunityController {
/**
* Method to join a community
* @param communityId the communityID of the community the user wants to join
* @throws StatusCodeException BadRequest When the
user does something stupid kekW
* @throws StatusCodeException BadRequest When the
community is private, the community does not exist or if the user is already in the community
*/
@Operation
(
summary
=
"
Add user to a
community"
)
@Operation
(
summary
=
"
Join an open
community"
)
@PostMapping
(
"/communities/{communityId}/join"
)
@ApiResponse
(
responseCode
=
"200"
,
description
=
"Added user to community"
)
@ApiResponse
(
responseCode
=
"400"
,
description
=
"Illegal operation"
)
...
...
@@ -54,7 +54,7 @@ public class UserCommunityController {
throw
new
StatusCodeException
(
HttpStatus
.
BAD_REQUEST
,
"Community does not exist"
);
}
if
(
communityDAO
.
getVisibility
()==
0
){
throw
new
StatusCodeException
(
HttpStatus
.
BAD_REQUEST
,
"This community is
invite only
"
);
throw
new
StatusCodeException
(
HttpStatus
.
BAD_REQUEST
,
"This community is
private
"
);
}
if
(
userCommunityService
.
userIsInCommunity
(
token
.
getAccountId
(),
communityDAO
)){
throw
new
StatusCodeException
(
HttpStatus
.
BAD_REQUEST
,
"User is already in this community"
);
...
...
@@ -66,9 +66,9 @@ public class UserCommunityController {
}
/**
*
* @param communityId the community id of the community the user
....
* @return
*
Method to check if user is in a given community
* @param communityId the community id of the community the user
wants to check if they're part of
* @return
true if the user is in the community, false if not
*/
@Operation
(
summary
=
"Get info about if the user is in community"
)
@GetMapping
(
"/communities/{communityId}/user/status"
)
...
...
@@ -144,6 +144,7 @@ public class UserCommunityController {
if
(!(
userCommunityService
.
userIsInCommunity
(
token
.
getAccountId
(),
communityDAO
))){
throw
new
StatusCodeException
(
HttpStatus
.
BAD_REQUEST
,
"User is not in this community"
);
}
assert
ucd
!=
null
;
if
(!(
userCommunityService
.
removeUserFromCommunity
(
ucd
))){
throw
new
StatusCodeException
(
HttpStatus
.
BAD_REQUEST
,
"Unexpected error"
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment