-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chat 229 typing event #75
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
91396f9
refactor: refactored dtos package
Troha7 440217d
feat: create TypingController and added getTypingEvent
Troha7 046d9b7
feat: added sendTyping function
Troha7 867c9ff
fix: added typingEventDto and fixed tests
Troha7 9ce7480
fix: renamed getTypingEvent -> updateTypingEvent
Troha7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/chat/yourway/controller/TypingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.chat.yourway.controller; | ||
|
||
import com.chat.yourway.service.interfaces.ChatTypingEventService; | ||
import java.security.Principal; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.messaging.handler.annotation.DestinationVariable; | ||
import org.springframework.messaging.handler.annotation.MessageMapping; | ||
import org.springframework.stereotype.Controller; | ||
|
||
@Controller | ||
@RequiredArgsConstructor | ||
public class TypingController { | ||
|
||
private final ChatTypingEventService chatTypingEventService; | ||
|
||
@MessageMapping("/typing/{isTyping}") | ||
public void getTypingEvent(@DestinationVariable boolean isTyping, Principal principal) { | ||
String email = principal.getName(); | ||
chatTypingEventService.getTypingEvent(isTyping, email); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...way/dto/response/ApiErrorResponseDto.java → ...o/response/error/ApiErrorResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dto/response/MessageErrorResponseDto.java → ...sponse/error/MessageErrorResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../dto/response/LastMessageResponseDto.java → .../notification/LastMessageResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ponse/MessageNotificationResponseDto.java → ...ation/MessageNotificationResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/chat/yourway/dto/response/notification/TypingEventResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.chat.yourway.dto.response.notification; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Setter | ||
@Getter | ||
@ToString | ||
public class TypingEventResponseDto { | ||
|
||
private String email; | ||
|
||
private boolean isTyping; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/chat/yourway/exception/handler/WebsocketExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/chat/yourway/service/ChatTypingEventServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.chat.yourway.service; | ||
|
||
import com.chat.yourway.model.event.EventType; | ||
import com.chat.yourway.service.interfaces.ChatNotificationService; | ||
import com.chat.yourway.service.interfaces.ChatTypingEventService; | ||
import com.chat.yourway.service.interfaces.ContactEventService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ChatTypingEventServiceImpl implements ChatTypingEventService { | ||
|
||
private final ContactEventService contactEventService; | ||
private final ChatNotificationService chatNotificationService; | ||
|
||
@Override | ||
public void getTypingEvent(Boolean isTyping, String email) { | ||
log.info("Start getTypingEvent isTyping={}, email={}", isTyping, email); | ||
contactEventService.updateTypingEvent(email, isTyping); | ||
|
||
Integer topicId = contactEventService.getAllByEmail(email).stream() | ||
.filter(e -> e.getEventType().equals(EventType.SUBSCRIBED)) | ||
.findFirst() | ||
.orElseThrow() | ||
.getTopicId(); | ||
|
||
chatNotificationService.updateNotificationForAllWhoSubscribedToTopic(topicId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/com/chat/yourway/service/NotificationServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/chat/yourway/service/interfaces/ChatTypingEventService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.chat.yourway.service.interfaces; | ||
|
||
public interface ChatTypingEventService { | ||
|
||
/** | ||
* Get typing event by user email. | ||
* | ||
* @param isTyping typing status. | ||
* @param email user email. | ||
*/ | ||
void getTypingEvent(Boolean isTyping, String email); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/com/chat/yourway/service/interfaces/NotificationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
трохи збиває з пантелику назва методу getTypingEvent. метод нічого не повертає хоча в назві get. навпаки він оновлює isTyping і робить оповіщення клієнтів.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Згоден) Давай виправлю на updateTypingEvent або запропонуй іншу назву.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateTypingEvent буде норм