Skip to content

Commit

Permalink
Merge pull request #95 from Onlineberatung/feat/VIC-786_Advice_seeker…
Browse files Browse the repository at this point in the history
…_books_a_meeting

Feat/vic 786 advice seeker books a meeting
  • Loading branch information
adnanalicic authored Jul 21, 2022
2 parents eb83a10 + a6baa2d commit a92b723
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
42 changes: 42 additions & 0 deletions api/messageservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,43 @@ paths:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]
/messages/aliasWithContent/new:
post:
tags:
- message-controller
summary: 'Saves a new system message containing the provided message type in the alias and
some content.
[Authorization: Role: user, consultant, technical]'
operationId: saveAliasMessageWithContent
parameters:
- name: rcGroupId
in: header
required: true
schema:
type: string
requestBody:
required: true
content:
'application/json':
schema:
$ref: '#/components/schemas/AliasMessageDTO'
responses:
201:
description: CREATED - message was successfully created
content:
'application/json':
schema:
$ref: '#/components/schemas/MessageResponseDTO'
400:
description: BAD REQUEST - invalid/incomplete request or body object
401:
description: UNAUTHORIZED - no/invalid Keycloak token
403:
description: FORBIDDEN - no/invalid role/authorization
500:
description: INTERNAL SERVER ERROR - server encountered unexpected condition
security:
- Bearer: [ ]

components:
schemas:
Expand Down Expand Up @@ -538,6 +575,8 @@ components:
$ref: '#/components/schemas/VideoCallMessageDTO'
messageType:
$ref: '#/components/schemas/MessageType'
content:
type: string

ForwardMessageDTO:
type: object
Expand Down Expand Up @@ -601,6 +640,9 @@ components:
MessageType:
type: string
enum:
- "APPOINTMENT_SET"
- "APPOINTMENT_CANCELLED"
- "APPOINTMENT_RESCHEDULED"
- "FINISHED_CONVERSATION"
- "FORWARD"
- "FURTHER_STEPS"
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/de/caritas/cob/messageservice/Messenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,19 @@ public boolean patchEventMessage(String rcToken, String rcUserId, String message

return isUpdated;
}

/**
* Posts a message which contains an alias with the provided {@link MessageType} in
* the specified Rocket.Chat group.
*
* @param rcGroupId Rocket.Chat group ID
* @param messageType {@link MessageType}
* @return {@link MessageResponseDTO}
*/
public MessageResponseDTO postAliasMessage(String rcGroupId, MessageType messageType, String content) {
AliasMessageDTO aliasMessageDTO = new AliasMessageDTO().messageType(messageType).content(content);
var response = this.rocketChatService.postAliasOnlyMessageAsSystemUser(rcGroupId,
aliasMessageDTO);
return mapper.messageResponseOf(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,25 @@ public ResponseEntity<Void> patchMessage(String rcToken, String rcUserId, String
? ResponseEntity.noContent().build()
: ResponseEntity.notFound().build();
}

/**
* Posts a message which contains an alias with the provided {@link MessageType} in the specified
* Rocket.Chat group.
*
* @param rcGroupId (required) Rocket.Chat group ID
* @param aliasOnlyMessageDTO {@link AliasOnlyMessageDTO}
* @return {@link ResponseEntity} with the {@link HttpStatus}
*/
@Override
public ResponseEntity<MessageResponseDTO> saveAliasMessageWithContent(
@RequestHeader String rcGroupId,
@Valid AliasMessageDTO aliasOnlyMessageDTO) {
var type = aliasOnlyMessageDTO.getMessageType();
var response = messenger
.postAliasMessage(rcGroupId, type, aliasOnlyMessageDTO.getContent());
return new ResponseEntity<>(response, HttpStatus.CREATED);
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void setMessageType(MessagesDTO msg) {

if (nonNull(msg.getAlias().getForwardMessageDTO())) {
msg.getAlias().setMessageType(MessageType.FORWARD);
} else {
} else if (nonNull(msg.getAlias().getVideoCallMessageDTO())) {
msg.getAlias().setMessageType(MessageType.VIDEOCALL);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ protected void configure(HttpSecurity http) throws Exception {
.hasAuthority(USE_FEEDBACK)
.antMatchers("/messages/aliasonly/new")
.hasAnyAuthority(USER_DEFAULT, CONSULTANT_DEFAULT, TECHNICAL_DEFAULT)
.antMatchers("/messages/aliasWithContent/new")
.hasAnyAuthority(USER_DEFAULT, CONSULTANT_DEFAULT, TECHNICAL_DEFAULT)
.anyRequest()
.denyAll();
}
Expand Down

0 comments on commit a92b723

Please sign in to comment.