Skip to content

Commit

Permalink
Merge pull request #11 from virtualidentityag/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
tkuzynow authored Dec 20, 2024
2 parents 247d3ac + 124dd72 commit 5ca625e
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 553 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dockerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: mvn -B -Pprod clean package -DskipTests
- name: Maven Verify
run: mvn -B -Pprod clean verify
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: targetfiles
path: target/*.jar
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Download buildfiles artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: targetfiles
- name: Get current time
Expand Down
76 changes: 0 additions & 76 deletions api/uploadservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,82 +105,6 @@ paths:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: []
/uploads/feedback/new/{feedbackRoomId}:
post:
tags:
- upload-controller
summary: 'Upload a file and send a message to to a Rocket.Chat feedback room
[Authorization: authority for feedback chat]'
operationId: uploadFileToFeedbackRoom
parameters:
- name: feedbackRoomId
in: path
description: Rocket.Chat room id
required: true
schema:
type: string
- name: RCToken
in: header
required: true
schema:
type: string
- name: RCUserId
in: header
required: true
schema:
type: string
requestBody:
content:
multipart/form-data:
schema:
required:
- file
- sendNotification
properties:
msg:
type: string
description: A text message
description:
type: string
description: A description of the file
tmId:
type: string
description: The thread message id (if you want upload a file to
a thread)
fileHeader:
type: string
description: Starting bytes of file which includes mimetype for verification
t:
type: string
description: Type of message
example: "e2e"
file:
type: string
description: File to upload
format: binary
sendNotification:
type: string
description: Flag, whether an email notification should be sent
or not (true/false)
required: true
responses:
201:
description: CREATED - upload was successfully performed
400:
description: BAD REQUEST - invalid/incomplete request or body object
401:
description: UNAUTHORIZED - no/invalid Keycloak token
403:
description: FORBIDDEN - no/invalid role/authorization
413:
description: REQUEST ENTITY TOO LARGE - Maximum upload size exceeded
415:
description: UNSUPPORTED MEDIA TYPE - Type of uploaded file is not allowed
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: []

components:
schemas:
MasterKeyDto:
Expand Down
25 changes: 24 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<version>2.7.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down Expand Up @@ -82,6 +95,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>3.1.11</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>

<!-- Swagger/OpenApi dependencies -->
<dependency>
Expand Down
63 changes: 0 additions & 63 deletions services/userservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,33 +538,6 @@ paths:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]
/users/mails/messages/feedback/new:
post:
tags:
- user-controller
summary: 'Sends a notification e-mail that a new feedback message/answer has
been written [Authorization: Role: consultant with authority for feedback
chat]'
operationId: sendNewFeedbackMessageNotification
requestBody:
content:
'application/json':
schema:
$ref: '#/components/schemas/NewMessageNotificationDTO'
required: true
responses:
200:
description: successful operation
400:
description: BAD REQUEST - invalid/incomplete request or body object
401:
description: UNAUTHORIZED - invalid token
409:
description: CONFLICT - no user e-mail address in db given
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]
/users/consultants:
get:
tags:
Expand Down Expand Up @@ -1180,10 +1153,6 @@ components:
type: string
example: xGklslk2JJKK
description: Rocket.Chat room ID
feedbackGroupId:
type: string
example: 8ertjlasdKJA
description: Rocket.Chat feedback room ID
askerRcId:
type: string
example: 8ertjlasdKJA
Expand All @@ -1198,9 +1167,6 @@ components:
messagesRead:
type: boolean
example: false
feedbackRead:
type: boolean
example: true
isTeamSession:
type: boolean
example: false
Expand Down Expand Up @@ -1231,35 +1197,11 @@ components:
AliasMessageDTO:
type: object
properties:
forwardMessageDTO:
$ref: '#/components/schemas/ForwardMessageDTO'
videoCallMessageDTO:
$ref: '#/components/schemas/VideoCallMessageDTO'
messageType:
$ref: '#/components/schemas/MessageType'

ForwardMessageDTO:
type: object
required:
- message
- timestamp
- username
- rcUserId
properties:
message:
type: string
example: "Lorem ipsum dolor sit amet, consetetur..."
timestamp:
type: string
description: "Full qualified timestamp"
example: "2018-11-15T09:33:00.057Z"
username:
type: string
example: "asker23"
rcUserId:
type: string
example: "ag89h3tjkerg94t"

VideoCallMessageDTO:
type: object
required:
Expand All @@ -1283,7 +1225,6 @@ components:
enum:
- "FURTHER_STEPS"
- "UPDATE_SESSION_DATA"
- "FORWARD"
- "VIDEOCALL"

ConsultantSessionDTO:
Expand Down Expand Up @@ -1312,10 +1253,6 @@ components:
type: string
example: xGklslk2JJKK
description: Rocket.Chat room ID
feedbackGroupId:
type: string
example: 8ertjlasdKJA
description: Rocket.Chat feedback room ID
consultantId:
type: string
example: 926b9777-4eef-443d-925a-4aa534797bd7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static de.caritas.cob.uploadservice.api.authorization.Authority.AuthorityValue.CONSULTANT_DEFAULT;
import static de.caritas.cob.uploadservice.api.authorization.Authority.AuthorityValue.TECHNICAL_DEFAULT;
import static de.caritas.cob.uploadservice.api.authorization.Authority.AuthorityValue.USER_DEFAULT;
import static de.caritas.cob.uploadservice.api.authorization.Authority.AuthorityValue.USE_FEEDBACK;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;

Expand All @@ -23,7 +22,6 @@ public enum Authority {

USER(UserRole.USER, singletonList(USER_DEFAULT)),
CONSULTANT(UserRole.CONSULTANT, singletonList(CONSULTANT_DEFAULT)),
U25_CONSULTANT(UserRole.PEER_CONSULTANT, singletonList(USE_FEEDBACK)),
TECHNICAL(UserRole.TECHNICAL, singletonList(TECHNICAL_DEFAULT)),
ANONYMOUS(UserRole.ANONYMOUS, singletonList(ANONYMOUS_DEFAULT));

Expand Down Expand Up @@ -54,7 +52,6 @@ private AuthorityValue() {

public static final String CONSULTANT_DEFAULT = PREFIX + "CONSULTANT_DEFAULT";
public static final String USER_DEFAULT = PREFIX + "USER_DEFAULT";
public static final String USE_FEEDBACK = PREFIX + "USE_FEEDBACK";
public static final String TECHNICAL_DEFAULT = PREFIX + "TECHNICAL_DEFAULT";
public static final String ANONYMOUS_DEFAULT = PREFIX + "ANONYMOUS_DEFAULT";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public enum UserRole {
USER("user"),
CONSULTANT("consultant"),
TECHNICAL("technical"),
PEER_CONSULTANT("peer-consultant"),
ANONYMOUS("anonymous");

private final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import de.caritas.cob.uploadservice.api.service.LogService;
import de.caritas.cob.uploadservice.generated.api.controller.UploadsApi;
import io.swagger.annotations.Api;
import java.util.Objects;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -105,54 +102,4 @@ public ResponseEntity<Void> uploadFileToRoom(

return new ResponseEntity<>(HttpStatus.CREATED);
}

/**
* Upload a file to a Rocket.Chat feedback room with a text message.
*
* @param feedbackRoomId Rocket.Chat feedback room id
* @param rcToken Rocket.Chat token
* @param rcUserId Rocket.Chat user id
* @param file The file object as {@link MultipartFile}
* @param sendNotification Flag, whether an email notification should be sent or not
* @param msg The message
* @param description The description
* @param tmId Rocket.Chat thread message id
* @return a ResponseEntity instance
*/
@TempCleanup
@Override
public ResponseEntity<Void> uploadFileToFeedbackRoom(
@PathVariable("feedbackRoomId") String feedbackRoomId,
@RequestHeader String rcToken,
@RequestHeader String rcUserId,
@RequestPart MultipartFile file,
@RequestParam String sendNotification,
@RequestPart(required = false) String t,
@RequestPart(required = false) String fileHeader,
@RequestParam(required = false) String msg,
@RequestParam(required = false) String description,
@RequestParam(required = false) String tmId) {

RocketChatCredentials rocketChatCredentials =
RocketChatCredentials.builder().rocketChatUserId(rcUserId).rocketChatToken(rcToken).build();

RocketChatUploadParameter rocketChatUploadParameter =
RocketChatUploadParameter.builder()
.roomId(feedbackRoomId)
.description(description)
.message(msg)
.file(file)
.tmId(tmId)
.build();

uploadFacade.uploadFileToFeedbackRoom(
rocketChatCredentials,
rocketChatUploadParameter,
parseBoolean(sendNotification),
t,
fileHeader
);

return new ResponseEntity<>(HttpStatus.CREATED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public class EmailNotificationFacade {
@Value("${user.service.api.new.message.notification}")
private String userServiceApiSendNewMessageNotificationUrl;

@Value("${user.service.api.new.feedback.message.notification}")
private String userServiceApiSendNewFeedbackMessageNotificationUrl;

@Autowired
public EmailNotificationFacade(
EmailNotificationHelper emailNotificationHelper, AuthenticatedUser authenticatedUser) {
Expand All @@ -42,16 +39,4 @@ public void sendEmailNotification(String rcGroupId) {
authenticatedUser.getAccessToken(),
Optional.ofNullable(TenantContext.getCurrentTenant()));
}

/**
* Sends a new feedback message notification via the UserService (user data needed for sending the
* mail will be read by the UserService, which in turn calls the UploadService).
*
* @param rcGroupId
*/
public void sendFeedbackEmailNotification(String rcGroupId) {
emailNotificationHelper.sendEmailFeedbackNotificationViaUserService(
rcGroupId,
authenticatedUser.getAccessToken(), Optional.ofNullable(TenantContext.getCurrentTenant()));
}
}
Loading

0 comments on commit 5ca625e

Please sign in to comment.