diff --git a/.gitignore b/.gitignore index 106f7fc143..1f4cf232d1 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,11 @@ # Gradle .idea/**/gradle.xml .idea/**/libraries +gradle/caches +gradle/.tmp +gradle/daemon +gradle/jdks +gradle/native # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, @@ -290,4 +295,7 @@ gradle-app.setting # Java heap dump *.hprof -# End of https://www.toptal.com/developers/gitignore/api/java,intellij,gradle,macos,windows,intellij+all \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/java,intellij,gradle,macos,windows,intellij+all + +application-dev.yml +.env \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0d76432937..67cbe92b61 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,12 @@ dependencies { // AWS S3 implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + // WebSocket + implementation 'org.springframework.boot:spring-boot-starter-websocket' + + // SockJs + implementation 'org.webjars:sockjs-client:1.5.1' + // QueryDSL implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0-bin.zip.lck b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0-bin.zip.lck new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0-bin.zip.ok b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0-bin.zip.ok new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/LICENSE b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/LICENSE new file mode 100644 index 0000000000..f013fd5ddb --- /dev/null +++ b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/LICENSE @@ -0,0 +1,420 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + +============================================================================== +Licenses for included components: + +------------------------------------------------------------------------------ +Eclipse Public License 1.0 +https://opensource.org/licenses/EPL-1.0 + +junit:junit +org.sonatype.aether:aether-api +org.sonatype.aether:aether-connector-wagon +org.sonatype.aether:aether-impl +org.sonatype.aether:aether-spi +org.sonatype.aether:aether-util + +------------------------------------------------------------------------------ +3-Clause BSD +https://opensource.org/licenses/BSD-3-Clause + +com.google.code.findbugs:jsr305 + +org.hamcrest:hamcrest-core +BSD License + +Copyright (c) 2000-2015 www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +com.esotericsoftware.kryo:kryo +com.esotericsoftware.minlog:minlog +Copyright (c) 2008-2018, Nathan Sweet All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of Esoteric Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +org.ow2.asm:asm +org.ow2.asm:asm-analysis +org.ow2.asm:asm-commons +org.ow2.asm:asm-tree +org.ow2.asm:asm-util +ASM: a very small and fast Java bytecode manipulation framework + Copyright (c) 2000-2011 INRIA, France Telecom + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------ +MIT + +com.googlecode.plist:dd-plist +dd-plist - An open source library to parse and generate property lists +Copyright (C) 2016 Daniel Dreibrodt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +org.bouncycastle:bcpg-jdk15on +org.bouncycastle:bcprov-jdk15on +Copyright (c) 2000 - 2019 The Legion of the Bouncy Castle Inc. (https://www.bouncycastle.org) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +org.slf4j:jcl-over-slf4j +org.slf4j:jul-to-slf4j +org.slf4j:log4j-over-slf4j +org.slf4j:slf4j-api + Copyright (c) 2004-2017 QOS.ch + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +------------------------------------------------------------------------------ +CDDL +https://opensource.org/licenses/CDDL-1.0 + +com.sun.xml.bind:jaxb-impl + +------------------------------------------------------------------------------ +LGPL 2.1 +https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html + +org.samba.jcifs:jcifs + +org.jetbrains.intellij.deps:trove4j + +------------------------------------------------------------------------------ +License for the GNU Trove library included by the Kotlin embeddable compiler +------------------------------------------------------------------------------ +The source code for GNU Trove is licensed under the Lesser GNU Public License (LGPL). + + Copyright (c) 2001, Eric D. Friedman All Rights Reserved. This library is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +Two classes (HashFunctions and PrimeFinder) included in Trove are licensed under the following terms: + + Copyright (c) 1999 CERN - European Organization for Nuclear Research. Permission to use, copy, modify, distribute and sell this software + and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and + that both that copyright notice and this permission notice appear in supporting documentation. CERN makes no representations about the + suitability of this software for any purpose. It is provided "as is" without expressed or implied warranty. + +The source code of modified GNU Trove library is available at + https://github.com/JetBrains/intellij-deps-trove4j (with trove4j_changes.txt describing the changes) + +------------------------------------------------------------------------------ +Eclipse Distribution License 1.0 +https://www.eclipse.org/org/documents/edl-v10.php + +org.eclipse.jgit:org.eclipse.jgit + +------------------------------------------------------------------------------ +BSD-style + +com.jcraft:jsch +com.jcraft:jzlib + +Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, +INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------ +Eclipse Public License 2.0 +https://www.eclipse.org/legal/epl-2.0/ + +org.junit.platform:junit-platform-launcher + +------------------------------------------------------------------------------ +Mozilla Public License 2.0 +https://www.mozilla.org/en-US/MPL/2.0/ + +org.mozilla:rhino diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/NOTICE b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/NOTICE new file mode 100644 index 0000000000..00a36efcde --- /dev/null +++ b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/NOTICE @@ -0,0 +1,21 @@ +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Gradle distribution. == +========================================================================= + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +It includes the following other software: + +Groovy (http://groovy-lang.org) +SLF4J (http://www.slf4j.org) +JUnit (http://www.junit.org) +JCIFS (http://jcifs.samba.org) +HttpClient (https://hc.apache.org/httpcomponents-client-4.5.x/) + +For licenses, see the LICENSE file. + +If any software distributed with Gradle does not have an Apache 2 License, its license is explicitly listed in the +LICENSE file. diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/README b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/README new file mode 100644 index 0000000000..97d48bdc51 --- /dev/null +++ b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/README @@ -0,0 +1,11 @@ +Gradle is a build tool with a focus on build automation and support for multi-language development. If you are building, testing, publishing, and deploying software on any platform, Gradle offers a flexible model that can support the entire development lifecycle from compiling and packaging code to publishing web sites. Gradle has been designed to support build automation across multiple languages and platforms including Java, Scala, Android, C/C++, and Groovy, and is closely integrated with development tools and continuous integration servers including Eclipse, IntelliJ, and Jenkins. + +For more information about Gradle, please visit: https://gradle.org + +If you are using the "all" distribution, the User Manual is included in your distribution. + +If you are using the "bin" distribution, a copy of the User Manual is available on https://docs.gradle.org. + +Typing `gradle help` prints the command line help. + +Typing `gradle tasks` shows all the tasks of a Gradle build. diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/bin/gradle b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/bin/gradle new file mode 100644 index 0000000000..5e152d7195 --- /dev/null +++ b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/bin/gradle @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}.." && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/lib/gradle-launcher-8.0.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.launcher.GradleMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/bin/gradle.bat b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/bin/gradle.bat new file mode 100644 index 0000000000..3d017f471e --- /dev/null +++ b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/bin/gradle.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME%.. + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\lib\gradle-launcher-8.0.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.launcher.GradleMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/init.d/readme.txt b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/init.d/readme.txt new file mode 100644 index 0000000000..d8e210f840 --- /dev/null +++ b/gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0/init.d/readme.txt @@ -0,0 +1 @@ +You can add .gradle (e.g. test.gradle) init scripts to this directory. Each one is executed at the start of the build. diff --git a/src/main/java/capstone/facefriend/chat/config/ChatConfig.java b/src/main/java/capstone/facefriend/chat/config/ChatConfig.java new file mode 100644 index 0000000000..d54818d4ba --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/config/ChatConfig.java @@ -0,0 +1,35 @@ +package capstone.facefriend.chat.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.simp.config.MessageBrokerRegistry; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; +import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +@Configuration +@EnableWebSocket +@EnableWebSocketMessageBroker +public class ChatConfig implements WebSocketMessageBrokerConfigurer { + + // sockJS Fallback을 이용해 노출할 endpoint 설정 + @Override + public void registerStompEndpoints(StompEndpointRegistry registry) { + // 웹소켓이 handshake를 하기 위해 연결하는 endpoint + registry.addEndpoint("/ws") + .setAllowedOriginPatterns("*"); +// .withSockJS(); + + } + + //메세지 브로커에 관한 설정 + @Override + public void configureMessageBroker(MessageBrokerRegistry registry) { + // 서버 -> 클라이언트로 발행하는 메세지에 대한 endpoint 설정 : 구독 + registry.enableSimpleBroker("/sub"); + + // 클라이언트->서버로 발행하는 메세지에 대한 endpoint 설정 : 구독에 대한 메세지 + registry.setApplicationDestinationPrefixes("/pub"); + } +} + diff --git a/src/main/java/capstone/facefriend/chat/config/RedisConfig.java b/src/main/java/capstone/facefriend/chat/config/RedisConfig.java new file mode 100644 index 0000000000..dd8851deef --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/config/RedisConfig.java @@ -0,0 +1,79 @@ +package capstone.facefriend.chat.config; + + +import capstone.facefriend.chat.service.RedisSubscriber; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.RedisStandaloneConfiguration; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +@RequiredArgsConstructor +public class RedisConfig { + @Value("${spring.data.redis.host}") + private String redisHost; + @Value("${spring.data.redis.port}") + private int redisPort; + + + @Bean + public RedisConnectionFactory redisConnectionFactory() { + RedisStandaloneConfiguration redisStandaloneConfiguration = + new RedisStandaloneConfiguration(redisHost, redisPort); + return new LettuceConnectionFactory(redisStandaloneConfiguration); + } + + @Bean + public RedisMessageListenerContainer redisMessageListenerContainer( + RedisConnectionFactory connectionFactory, + MessageListenerAdapter listenerAdapter, + ChannelTopic channelTopic + ) { + RedisMessageListenerContainer container = new RedisMessageListenerContainer(); + container.setConnectionFactory(connectionFactory); + // RedisMessageListenerContainer 에 Bean 으로 등록한 listenerAdapter, channelTopic 추가 + container.addMessageListener(listenerAdapter, channelTopic); + return container; + } + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(redisConnectionFactory); + + // Jackson2JsonRedisSerializer를 사용하여 RedisTemplate 설정 + Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer<>(Object.class); + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); // Java 8 시간 모듈 등록 + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // 날짜를 타임스탬프로 변환하지 않도록 설정 + serializer.setObjectMapper(objectMapper); + + // 문자열 직렬화 설정 + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(serializer); + + redisTemplate.afterPropertiesSet(); + return redisTemplate; + } + + @Bean + public MessageListenerAdapter listenerAdapter(RedisSubscriber subscriber) { + return new MessageListenerAdapter(subscriber, "sendMessage"); + } + + @Bean + public ChannelTopic channelTopic() {return new ChannelTopic("chatroom");} + +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/controller/ChatRoomController.java b/src/main/java/capstone/facefriend/chat/controller/ChatRoomController.java new file mode 100644 index 0000000000..3ccfb34806 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/controller/ChatRoomController.java @@ -0,0 +1,25 @@ +package capstone.facefriend.chat.controller; + +import capstone.facefriend.auth.controller.support.AuthMember; +import capstone.facefriend.chat.service.ChatRoomService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@Slf4j +@RequiredArgsConstructor +public class ChatRoomController { + private final ChatRoomService chatRoomService; + + @GetMapping("/room/list") + ResponseEntity> getChatRoomList( + @AuthMember Long memberId + ) { + return ResponseEntity.ok(chatRoomService.getChatRoomList(memberId)); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/controller/MessageController.java b/src/main/java/capstone/facefriend/chat/controller/MessageController.java new file mode 100644 index 0000000000..6ea040fa1a --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/controller/MessageController.java @@ -0,0 +1,67 @@ +package capstone.facefriend.chat.controller; + +import capstone.facefriend.auth.infrastructure.JwtProvider; +import capstone.facefriend.chat.service.dto.heart.HeartReplyRequest; +import capstone.facefriend.chat.service.dto.message.MessageRequest; +import capstone.facefriend.chat.service.dto.heart.SendHeartRequest; +import capstone.facefriend.chat.service.MessageService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.messaging.handler.annotation.MessageMapping; +import org.springframework.messaging.handler.annotation.SendTo; +import org.springframework.messaging.simp.stomp.StompHeaderAccessor; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Slf4j +@RequiredArgsConstructor +public class MessageController { + + private static final String BEARER_PREFIX = "Bearer "; + private final MessageService messageService; + private final MappingJackson2HttpMessageConverter converter; + private final JwtProvider jwtProvider; + + @MessageMapping("/test") + @SendTo("/sub/test") + public String test() { + return "테스트 메시지"; + } + + @MessageMapping("/chat/messages") + public void message( + StompHeaderAccessor headerAccessor, + MessageRequest messageRequest + ) { + String authorizationHeader = headerAccessor.getFirstNativeHeader("Authorization"); + String token = authorizationHeader.substring(BEARER_PREFIX.length()); + Long senderId = jwtProvider.extractId(token); + messageService.sendMessage(messageRequest, senderId); + } + + @MessageMapping("/chat/send-heart") + public void sendheart( + StompHeaderAccessor headerAccessor, + @RequestBody SendHeartRequest sendHeartRequest + ){ + String authorizationHeader = headerAccessor.getFirstNativeHeader("Authorization"); + String token = authorizationHeader.substring(BEARER_PREFIX.length()); + Long senderId = jwtProvider.extractId(token); + messageService.sendHeart(senderId, sendHeartRequest.getReceiveId()); + } + + @MessageMapping("/chat/heart-reply") + public void heartreply( + StompHeaderAccessor headerAccessor, + HeartReplyRequest heartReplyRequest + ) { + String authorizationHeader = headerAccessor.getFirstNativeHeader("Authorization"); + String token = authorizationHeader.substring(BEARER_PREFIX.length()); + Long receiveId = jwtProvider.extractId(token); + + messageService.heartReply(heartReplyRequest, receiveId); + } + +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/domain/ChatMessage.java b/src/main/java/capstone/facefriend/chat/domain/ChatMessage.java new file mode 100644 index 0000000000..46f80a2ebe --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/domain/ChatMessage.java @@ -0,0 +1,51 @@ +package capstone.facefriend.chat.domain; + +import capstone.facefriend.common.domain.BaseEntity; +import capstone.facefriend.member.domain.member.Member; +import jakarta.persistence.*; +import lombok.*; +import lombok.extern.slf4j.Slf4j; +import org.hibernate.annotations.DynamicInsert; + +import java.time.LocalDateTime; + +@Getter +@Setter +@Builder +@EqualsAndHashCode(of = "id", callSuper = false) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +@Slf4j +@DynamicInsert +public class ChatMessage extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + private String content; + + @Column(nullable = false) + private LocalDateTime sendTime; + + @Column + private boolean isRead; + + @ManyToOne + @JoinColumn(name = "SENDER_ID") + private Member sender; + + @ManyToOne + @JoinColumn(name = "ROOM_ID") + private ChatRoom chatRoom; + + public void setMember(Member sender) { + this.sender = sender; + } + + public void setChatRoom(ChatRoom ChatRoom) { + this.chatRoom = ChatRoom; + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/domain/ChatRoom.java b/src/main/java/capstone/facefriend/chat/domain/ChatRoom.java new file mode 100644 index 0000000000..e2daef07ed --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/domain/ChatRoom.java @@ -0,0 +1,50 @@ +package capstone.facefriend.chat.domain; + +import capstone.facefriend.common.domain.BaseEntity; +import jakarta.persistence.*; +import lombok.*; +import lombok.extern.slf4j.Slf4j; +import org.hibernate.annotations.DynamicInsert; + +@Getter +@Setter +@Builder +@EqualsAndHashCode(of = "id", callSuper = false) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +@Slf4j +@DynamicInsert +public class ChatRoom extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Enumerated(EnumType.STRING) + @Column + private Status status = Status.set; + + @Column + private boolean isPublic; + + public enum Status { + set("Set"), + open("Open"), + + progress("Progres"), + close("Close"), + delete("Delete"); + private final String value; + + Status(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/domain/ChatRoomMember.java b/src/main/java/capstone/facefriend/chat/domain/ChatRoomMember.java new file mode 100644 index 0000000000..5a3e250c92 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/domain/ChatRoomMember.java @@ -0,0 +1,65 @@ +package capstone.facefriend.chat.domain; + +import capstone.facefriend.common.domain.BaseEntity; +import capstone.facefriend.member.domain.member.Member; +import jakarta.persistence.*; +import lombok.*; +import lombok.extern.slf4j.Slf4j; +import org.hibernate.annotations.DynamicInsert; + +@Getter +@Setter +@Builder +@EqualsAndHashCode(of = "id", callSuper = false) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +@Slf4j +@DynamicInsert +public class ChatRoomMember extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "Room_ID") + private ChatRoom chatRoom; + + @ManyToOne + @JoinColumn(name = "SENDER_ID") + private Member sender; + + @ManyToOne + @JoinColumn(name = "RECEIVER_ID") + private Member receiver; + + @Column + private boolean isSenderExist; + + @Column + private boolean isReceiverExist; + + @Column + private boolean isSenderPublic; + + @Column + private boolean isReceiverPublic; + + public void setChatRoom(ChatRoom chatRoom) { + this.chatRoom = chatRoom; + } + public void setSender(Member Sender) { + this.sender = sender; + } + public void setReceiver(Member Sender) { + this.receiver = receiver; + } + + public boolean isSenderExist() {return this.isSenderExist == true;} + public boolean isReceiverExist() {return this.isReceiverExist == true;} + public boolean isSenderPublic() {return this.isSenderPublic == true;} + public boolean isReceiverPublic() {return this.isReceiverPublic == true;} + + +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/exception/ChatException.java b/src/main/java/capstone/facefriend/chat/exception/ChatException.java new file mode 100644 index 0000000000..d82e698859 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/exception/ChatException.java @@ -0,0 +1,10 @@ +package capstone.facefriend.chat.exception; + +import capstone.facefriend.common.exception.BaseException; +import capstone.facefriend.common.exception.ExceptionType; + +public class ChatException extends BaseException { + public ChatException(ExceptionType exceptionType) { + super(exceptionType); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/exception/ChatExceptionType.java b/src/main/java/capstone/facefriend/chat/exception/ChatExceptionType.java new file mode 100644 index 0000000000..afea94e745 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/exception/ChatExceptionType.java @@ -0,0 +1,46 @@ +package capstone.facefriend.chat.exception; + +import capstone.facefriend.common.exception.ExceptionType; +import capstone.facefriend.common.exception.Status; + +public enum ChatExceptionType implements ExceptionType { + NOT_FOUND(Status.NOT_FOUND, 5001, "일치하는 채팅방이 없습니다."), + INVALIDED_CHATROOM(Status.BAD_REQUEST, 5002, "유효한 채팅방이 아닙니다"), + INVALID_ACCESS(Status.FORBIDDEN, 5003, "본인의 계정이 아닙니다."), + UNAUTHORIZED(Status.UNAUTHORIZED, 5005, "접근 정보가 잘못되었습니다."), + ALREADY_CHATROOM(Status.BAD_REQUEST, 5006, "이미 존재하는 채팅방입니다."), + WRONG_PASSWORD(Status.BAD_REQUEST, 5007, "잘못된 비밀번호입니다."), + EXPIRED_ACCESS_TOKEN(Status.BAD_REQUEST, 5008, "만료된 액세스 토큰이므로 재발급해야 합니다."), + INVALID_ACCESS_TOKEN(Status.BAD_REQUEST, 5009, "유효하지 않은 액세스 토큰이므로 재발급해야 합니다."), + INVALID_REFRESH_TOKEN(Status.BAD_REQUEST, 5010, "유효하지 않은 리프레시 토큰입니다. 토큰 재발급이 불가능합니다."), + ACCESS_TOKEN_IS_IN_BLACKLIST(Status.BAD_REQUEST, 5011, "액세스 토큰이 로그아웃 처리되었습니다. 재로그인하시기 바랍니다."), + NOT_VERIFIED(Status.BAD_REQUEST, 5012, "본인 인증을 먼저 완료해야 합니다."), + PASSWORDS_NOT_EQUAL(Status.BAD_REQUEST, 5013, "재설정하는 비밀번호들이 동일하지 않습니다."), + WRONG_TEMPORARY_PASSWORD(Status.BAD_REQUEST, 5014, "임시 비밀번호가 올바르지 않습니다."), + NOT_FOUND_GENDER(Status.NOT_FOUND, 5015, "일치하는 성별이 없습니다.") + ; + private final Status status; + private final int exceptionCode; + private final String message; + + ChatExceptionType(Status status, int exceptionCode, String message) { + this.status = status; + this.exceptionCode = exceptionCode; + this.message = message; + } + + @Override + public Status status() { + return status; + } + + @Override + public int exceptionCode() { + return exceptionCode; + } + + @Override + public String message() { + return message; + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/repository/ChatMessageRepository.java b/src/main/java/capstone/facefriend/chat/repository/ChatMessageRepository.java new file mode 100644 index 0000000000..f6a20281f5 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/repository/ChatMessageRepository.java @@ -0,0 +1,11 @@ +package capstone.facefriend.chat.repository; + +import capstone.facefriend.chat.domain.ChatMessage; +import org.springframework.data.jpa.repository.JpaRepository; + + +public interface ChatMessageRepository extends JpaRepository { + ChatMessage findFirstByChatRoomIdOrderBySendTimeDesc(Long roomId); + ChatMessage save(ChatMessage chatMessage); + +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/repository/ChatRoomMemberRepository.java b/src/main/java/capstone/facefriend/chat/repository/ChatRoomMemberRepository.java new file mode 100644 index 0000000000..7cb178a2ad --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/repository/ChatRoomMemberRepository.java @@ -0,0 +1,23 @@ +package capstone.facefriend.chat.repository; + +import capstone.facefriend.chat.domain.ChatRoom; +import capstone.facefriend.chat.domain.ChatRoomMember; +import io.lettuce.core.dynamic.annotation.Param; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; +import java.util.Optional; + +public interface ChatRoomMemberRepository extends JpaRepository { + Optional findByChatRoom(ChatRoom chatRoom); + + @Query("SELECT c FROM ChatRoomMember c WHERE c.sender.id = :senderId AND c.receiver.id = :receiverId") + Optional findBySenderAndReceiver(@Param("senderId") Long senderId, @Param("receiverId") Long receiverId); + + // Optional findChatRoomMemberBySenderAAndReceiver(Member sender, Member receiver); + ChatRoomMember save(ChatRoomMember chatRoomMember); + + Optional> findAllBySenderId(Long senderId); + Optional> findAllByReceiverId(Long senderId); +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/repository/ChatRoomRepository.java b/src/main/java/capstone/facefriend/chat/repository/ChatRoomRepository.java new file mode 100644 index 0000000000..8a7da8f716 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/repository/ChatRoomRepository.java @@ -0,0 +1,10 @@ +package capstone.facefriend.chat.repository; + +import capstone.facefriend.chat.domain.ChatRoom; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; +public interface ChatRoomRepository extends JpaRepository { + Optional findById(Long id); + ChatRoom save(ChatRoom chatRoom); +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java b/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java new file mode 100644 index 0000000000..2bc79438c0 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java @@ -0,0 +1,92 @@ +package capstone.facefriend.chat.service; + +import capstone.facefriend.chat.domain.ChatMessage; +import capstone.facefriend.chat.domain.ChatRoom; +import capstone.facefriend.chat.domain.ChatRoomMember; +import capstone.facefriend.chat.repository.ChatMessageRepository; +import capstone.facefriend.chat.repository.ChatRoomMemberRepository; +import capstone.facefriend.chat.service.dto.chatroom.ChatRoomEmptyResponse; +import capstone.facefriend.chat.service.dto.chatroom.ChatRoomHeartResponse; +import capstone.facefriend.chat.service.dto.chatroom.ChatRoomMessageResponse; +import capstone.facefriend.chat.service.dto.chatroom.ChatRoomOpenResponse; +import capstone.facefriend.chat.service.dto.heart.GetSendHeartResponse; +import capstone.facefriend.member.domain.member.Member; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@Slf4j +@RequiredArgsConstructor +public class ChatRoomService { + + private final ChatRoomMemberRepository chatRoomMemberRepository; + private final ChatMessageRepository chatMessageRepository; + private static final String EMPTY_MESSAGE = "채팅을 시작하지 않았습니다."; + private static final String OPEN_MESSAGE = "채팅을 시작해보세요!"; + + private List findAllChatRoomMemberBySenderId(Long memberId) { + return chatRoomMemberRepository.findAllBySenderId(memberId).orElse(new ArrayList<>()); + } + + private List findAllChatRoomMemberByReceiverId(Long memberId) { + return chatRoomMemberRepository.findAllByReceiverId(memberId).orElse(new ArrayList<>()); + } + + @Transactional + public Map getChatRoomList(Long memberId) { + + List chatRoomMemberList = new ArrayList<>(); + chatRoomMemberList.addAll(findAllChatRoomMemberByReceiverId(memberId)); + chatRoomMemberList.addAll(findAllChatRoomMemberBySenderId(memberId)); + + Map chatRooms = new HashMap<>(); + + if (chatRoomMemberList.isEmpty()) { + ChatRoomEmptyResponse chatRoomEmptyResponse = ChatRoomEmptyResponse.of(EMPTY_MESSAGE); + chatRooms.put("chatRoomList", chatRoomEmptyResponse); + return chatRooms; + } + + List chatRoomsMessage = new ArrayList<>(); + List chatRoomsHeart = new ArrayList<>(); + List chatRoomsOpen = new ArrayList<>(); + + for (ChatRoomMember chatRoomMember : chatRoomMemberList) { + ChatRoom.Status status = chatRoomMember.getChatRoom().getStatus(); + + if (status == ChatRoom.Status.set) { + GetSendHeartResponse sendHeartResponse = new GetSendHeartResponse(); + sendHeartResponse.setType("Heart"); + sendHeartResponse.setRoomId(chatRoomMember.getChatRoom().getId()); + sendHeartResponse.setSenderId(chatRoomMember.getSender().getId()); + sendHeartResponse.setReceiveId(chatRoomMember.getReceiver().getId()); + sendHeartResponse.setSenderName(chatRoomMember.getSender().getBasicInfo().getNickname()); + ChatRoomHeartResponse chatRoomHeartResponse = ChatRoomHeartResponse.of(chatRoomMember, sendHeartResponse); + chatRoomsHeart.add(chatRoomHeartResponse); + + } else if (status == ChatRoom.Status.progress) { + ChatMessage chatMessage = chatMessageRepository.findFirstByChatRoomIdOrderBySendTimeDesc(chatRoomMember.getChatRoom().getId()); + ChatRoomMessageResponse chatRoomResponse = ChatRoomMessageResponse.of(chatRoomMember, chatMessage); + chatRoomsMessage.add(chatRoomResponse); + + } else if (status == ChatRoom.Status.open) { + Member Sender = chatRoomMember.getSender(); + ChatRoomOpenResponse chatRoomOpenResponse = ChatRoomOpenResponse.of(Sender.getId(), Sender.getBasicInfo().getNickname(), OPEN_MESSAGE); + chatRoomsOpen.add(chatRoomOpenResponse); + } + } + + chatRooms.put("chatRoomHeartList", chatRoomsHeart); + chatRooms.put("chatRoomMessageList", chatRoomsMessage); + chatRooms.put("chatRoomOpenList", chatRoomsOpen); + + return chatRooms; + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/MessageService.java b/src/main/java/capstone/facefriend/chat/service/MessageService.java new file mode 100644 index 0000000000..831f589008 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/MessageService.java @@ -0,0 +1,177 @@ +package capstone.facefriend.chat.service; + +import capstone.facefriend.chat.domain.ChatMessage; +import capstone.facefriend.chat.domain.ChatRoom; +import capstone.facefriend.chat.domain.ChatRoomMember; +import capstone.facefriend.chat.exception.ChatException; +import capstone.facefriend.chat.exception.ChatExceptionType; +import capstone.facefriend.chat.repository.ChatMessageRepository; +import capstone.facefriend.chat.repository.ChatRoomMemberRepository; +import capstone.facefriend.chat.repository.ChatRoomRepository; +import capstone.facefriend.chat.service.dto.heart.HeartReplyRequest; +import capstone.facefriend.chat.service.dto.heart.SendHeartResponse; +import capstone.facefriend.chat.service.dto.message.MessageRequest; +import capstone.facefriend.chat.service.dto.message.MessageResponse; +import capstone.facefriend.member.domain.member.Member; +import capstone.facefriend.member.domain.member.MemberRepository; +import capstone.facefriend.member.exception.member.MemberException; +import capstone.facefriend.member.exception.member.MemberExceptionType; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; + +@Service +@Slf4j +@RequiredArgsConstructor +public class MessageService { + + private final ChatMessageRepository chatMessageRepository; + private final ChatRoomMemberRepository chatRoomMemberRepository; + private final MemberRepository memberRepository; + private final ChatRoomRepository chatRoomRepository; + private final RedisTemplate redisTemplate; + private final ChannelTopic channelTopic; + private final SimpMessagingTemplate messagingTemplate; + + private Member findMemberById(Long memberId) { + Member member = memberRepository.findById(memberId) + .orElseThrow(() -> new MemberException(MemberExceptionType.NOT_FOUND)); + return member; + } + + private ChatRoom findRoomById(Long roomId) { + ChatRoom chatRoom = chatRoomRepository.findById(roomId) + .orElseThrow(()-> new ChatException(ChatExceptionType.NOT_FOUND)); + return chatRoom; + } + + private ChatRoomMember findSenderReceiver(Long senderId, Long receiveId) { + ChatRoomMember chatRoomMember = chatRoomMemberRepository.findBySenderAndReceiver(senderId, receiveId) + .orElseThrow(()-> new ChatException(ChatExceptionType.NOT_FOUND)); + return chatRoomMember; + } + + + @Transactional + public void sendMessage(MessageRequest messageRequest, Long senderId) { + Member sender = findMemberById(senderId); + Member receiver = findMemberById(messageRequest.getReceiveId()); + ChatRoomMember chatRoomMember = findSenderReceiver(sender.getId(), receiver.getId()); + ChatRoom chatRoom = findRoomById(messageRequest.getRoomId()); + + if (chatRoom.getStatus() == ChatRoom.Status.open) { + chatRoom.setStatus(ChatRoom.Status.progress); + chatRoomRepository.save(chatRoom); + chatRoomMemberRepository.save(chatRoomMember); + } else if ((chatRoom.getStatus() == ChatRoom.Status.close)) { + throw new ChatException(ChatExceptionType.INVALIDED_CHATROOM); + } else if ((chatRoom.getStatus() == ChatRoom.Status.set)) { + throw new ChatException(ChatExceptionType.INVALIDED_CHATROOM); + } else if ((chatRoom.getStatus() == ChatRoom.Status.delete)) { + throw new ChatException(ChatExceptionType.INVALIDED_CHATROOM); + } + + + ChatMessage chatMessage = ChatMessage.builder() + .content(messageRequest.getContent()) + .sender(sender) + .chatRoom(chatRoom) + .sendTime(LocalDateTime.now()) + .isRead(false) + .build(); + + chatMessageRepository.save(chatMessage); + + MessageResponse messageResponse = new MessageResponse(); + messageResponse.setRoomId(chatMessage.getChatRoom().getId()); + messageResponse.setSenderId(senderId); + messageResponse.setReceiveId(receiver.getId()); + messageResponse.setSenderNickname(sender.getBasicInfo().getNickname()); + messageResponse.setContent(chatMessage.getContent()); + messageResponse.setType("message"); + messageResponse.setCreatedAt(chatMessage.getSendTime()); + messageResponse.setIsRead(chatMessage.isRead()); + + String topic = channelTopic.getTopic(); + + redisTemplate.convertAndSend(topic, messageResponse); + + } + @Transactional + public void sendHeart(Long senderId, Long receiveId) { + + + ChatRoom chatRoom = ChatRoom.builder() + .status(ChatRoom.Status.set) + .isPublic(false) + .build(); + chatRoomRepository.save(chatRoom); + + Member sender = findMemberById(senderId); + Member receiver = findMemberById(receiveId); + + + if (chatRoomMemberRepository.findBySenderAndReceiver(senderId, receiveId).isPresent()) + throw new ChatException(ChatExceptionType.ALREADY_CHATROOM); + + + ChatRoomMember chatRoomMember = ChatRoomMember.builder() + .chatRoom(chatRoom) + .sender(sender) + .receiver(receiver) + .isSenderExist(false) + .isReceiverExist(false) + .isSenderPublic(false) + .isReceiverPublic(false) + .build(); + + chatRoomMemberRepository.save(chatRoomMember); + + SendHeartResponse sendHeartResponse = new SendHeartResponse(); + sendHeartResponse.setRoomId(chatRoom.getId()); + sendHeartResponse.setSenderId(sender.getId()); + sendHeartResponse.setReceiveId(receiveId); + sendHeartResponse.setSenderName(sender.getBasicInfo().getNickname()); + sendHeartResponse.setCreatedAt(LocalDateTime.now()); + sendHeartResponse.setType("Heart"); + + String topic = channelTopic.getTopic(); + redisTemplate.convertAndSend(topic, sendHeartResponse); + } + @Transactional + public void heartReply(HeartReplyRequest heartReplyRequest, Long receiveId) { + String message = null; + + Member receiver = findMemberById(receiveId); + Member sender = findMemberById(heartReplyRequest.getSenderId()); + + ChatRoomMember chatRoomMember = findSenderReceiver(sender.getId(), receiver.getId()); + ChatRoom chatRoom = findRoomById(chatRoomMember.getChatRoom().getId()); + + if (heartReplyRequest.getIntention().equals("positive")) { + chatRoom.setStatus(ChatRoom.Status.open); + chatRoomRepository.save(chatRoom); + chatRoomMemberRepository.save(chatRoomMember); + + message = receiver.getBasicInfo().getNickname() + "님이 수락했습니다."; + } else if (heartReplyRequest.getIntention().equals("negative")) { + chatRoomMemberRepository.delete(chatRoomMember); + chatRoomRepository.delete(chatRoom); + + message = receiver.getBasicInfo().getNickname() + "님이 거절했습니다."; + } else { + throw new ChatException(ChatExceptionType.ALREADY_CHATROOM); + } + // 동적으로 목적지 설정 + String destination = "/sub/chat/" + sender.getId(); + + // 메시지 전송 + messagingTemplate.convertAndSend(destination, message); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/RedisSubscriber.java b/src/main/java/capstone/facefriend/chat/service/RedisSubscriber.java new file mode 100644 index 0000000000..6b9de1fcb4 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/RedisSubscriber.java @@ -0,0 +1,52 @@ +package capstone.facefriend.chat.service; + +import capstone.facefriend.chat.service.dto.message.GetMessageResponse; +import capstone.facefriend.chat.service.dto.heart.GetSendHeartResponse; +import capstone.facefriend.chat.service.dto.message.MessageResponse; +import capstone.facefriend.chat.service.dto.heart.SendHeartResponse; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.messaging.simp.SimpMessageSendingOperations; +import org.springframework.stereotype.Service; + +import java.io.IOException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class RedisSubscriber implements MessageListener { + + private final ObjectMapper objectMapper; + private final RedisTemplate redisTemplate; + private final SimpMessageSendingOperations messagingTemplate; + + @Override + public void onMessage(Message message, byte[] pattern) { + try { + + // redis에서 발행된 데이터를 받아 역직렬화 + String publishMessage = (String) redisTemplate.getStringSerializer().deserialize(message.getBody()); + + if (publishMessage.contains("message")) { + MessageResponse messageResponse = objectMapper.readValue(publishMessage, MessageResponse.class); + + GetMessageResponse chatMessageResponse = new GetMessageResponse(messageResponse); + + messagingTemplate.convertAndSend("/sub/chat/" + messageResponse.getReceiveId(), chatMessageResponse); + + } else if (publishMessage.contains("Heart")) { + SendHeartResponse sendHeartResponse = objectMapper.readValue(publishMessage, SendHeartResponse.class); + + GetSendHeartResponse chatSendHeartResponse = new GetSendHeartResponse(sendHeartResponse); + + messagingTemplate.convertAndSend("/sub/chat/" + sendHeartResponse.getReceiveId(), chatSendHeartResponse); + } + } catch (IOException e) { + throw new RuntimeException("Failed to process message", e); + } + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomEmptyResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomEmptyResponse.java new file mode 100644 index 0000000000..ae7050b979 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomEmptyResponse.java @@ -0,0 +1,13 @@ +package capstone.facefriend.chat.service.dto.chatroom; + +public record ChatRoomEmptyResponse( + Boolean isEmpty, + String message +){ + public static ChatRoomEmptyResponse of(String message) { + return new ChatRoomEmptyResponse( + true, + message + ); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java new file mode 100644 index 0000000000..d3a9457690 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java @@ -0,0 +1,22 @@ +package capstone.facefriend.chat.service.dto.chatroom; + +import capstone.facefriend.chat.domain.ChatRoom; +import capstone.facefriend.chat.domain.ChatRoomMember; +import capstone.facefriend.chat.service.dto.heart.GetSendHeartResponse; + +public record ChatRoomHeartResponse ( + Long sender, + Long receiver, + ChatRoom chatRoom, + GetSendHeartResponse sendHeart + +) { + public static ChatRoomHeartResponse of(ChatRoomMember chatRoomMember, GetSendHeartResponse sendHeartResponse) { + return new ChatRoomHeartResponse( + chatRoomMember.getSender().getId(), + chatRoomMember.getReceiver().getId(), + chatRoomMember.getChatRoom(), + sendHeartResponse + ); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java new file mode 100644 index 0000000000..9d037bd3b4 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java @@ -0,0 +1,32 @@ +package capstone.facefriend.chat.service.dto.chatroom; + +import capstone.facefriend.chat.domain.ChatMessage; +import capstone.facefriend.chat.domain.ChatRoom; +import capstone.facefriend.chat.domain.ChatRoomMember; + +import java.time.LocalDateTime; + +public record ChatRoomMessageResponse( + Long sender, + Long receiver, + ChatRoom chatRoom, + String content, + LocalDateTime sendTime, + String senderNickname, + String senderGeneratedFaceInfo, + String senderOriginalFaceInfo + +){ + public static ChatRoomMessageResponse of(ChatRoomMember chatRoomMember, ChatMessage message) { + return new ChatRoomMessageResponse( + chatRoomMember.getSender().getId(), + chatRoomMember.getReceiver().getId(), + chatRoomMember.getChatRoom(), + message.getContent(), + message.getSendTime(), + message.getSender().getBasicInfo().getNickname(), + message.getSender().getFaceInfo().getGeneratedS3url(), + message.getSender().getFaceInfo().getOriginS3url() + ); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java new file mode 100644 index 0000000000..393f9a8880 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java @@ -0,0 +1,15 @@ +package capstone.facefriend.chat.service.dto.chatroom; + +public record ChatRoomOpenResponse ( + Long senderId, + String senderNickname, + String message +) { + public static ChatRoomOpenResponse of(Long senderId, String senderNickname, String message) { + return new ChatRoomOpenResponse( + senderId, + senderNickname, + message + ); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/heart/GetSendHeartResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/heart/GetSendHeartResponse.java new file mode 100644 index 0000000000..69645c8461 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/heart/GetSendHeartResponse.java @@ -0,0 +1,31 @@ +package capstone.facefriend.chat.service.dto.heart; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.time.LocalDateTime; + + +@Data +@NoArgsConstructor +public class GetSendHeartResponse { + private String senderName; + private Long senderId; + private Long receiveId; + private String type; + private Long roomId; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Seoul") + private LocalDateTime createdAt; + + + public GetSendHeartResponse(SendHeartResponse sendHeartResponse) { + this.senderName = sendHeartResponse.getSenderName(); + this.senderId = sendHeartResponse.getSenderId(); + this.receiveId = sendHeartResponse.getReceiveId(); + this.type = sendHeartResponse.getType(); + this.roomId = sendHeartResponse.getRoomId(); + this.createdAt = sendHeartResponse.getCreatedAt(); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/heart/HeartReplyRequest.java b/src/main/java/capstone/facefriend/chat/service/dto/heart/HeartReplyRequest.java new file mode 100644 index 0000000000..22b42fdfa4 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/heart/HeartReplyRequest.java @@ -0,0 +1,11 @@ +package capstone.facefriend.chat.service.dto.heart; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class HeartReplyRequest { + Long senderId; + String intention; +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/heart/SendHeartRequest.java b/src/main/java/capstone/facefriend/chat/service/dto/heart/SendHeartRequest.java new file mode 100644 index 0000000000..d659c4bb23 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/heart/SendHeartRequest.java @@ -0,0 +1,10 @@ +package capstone.facefriend.chat.service.dto.heart; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +@Data +public class SendHeartRequest { + private Long receiveId; +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/heart/SendHeartResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/heart/SendHeartResponse.java new file mode 100644 index 0000000000..438e842d61 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/heart/SendHeartResponse.java @@ -0,0 +1,22 @@ +package capstone.facefriend.chat.service.dto.heart; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.*; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SendHeartResponse implements Serializable { + private Long roomId; + private Long senderId; + private Long receiveId; + private String senderName; + private String type; + private String sessionId; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Seoul") + private LocalDateTime createdAt; + +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/message/GetMessageResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/message/GetMessageResponse.java new file mode 100644 index 0000000000..2b80749085 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/message/GetMessageResponse.java @@ -0,0 +1,33 @@ +package capstone.facefriend.chat.service.dto.message; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + + +@Data +@NoArgsConstructor +public class GetMessageResponse { + private Long roomId; + private Long senderId; + private Long receiveId; + private String senderNickname; + private String type; + private String content; + @JsonFormat(pattern = "yyyy-MM-dd hh:mm", timezone = "Asia/Seoul") + private LocalDateTime createdAt; + private Boolean isRead; + + public GetMessageResponse(MessageResponse messageResponse) { + this.roomId = messageResponse.getRoomId(); + this.senderId = messageResponse.getSenderId(); + this.receiveId = messageResponse.getReceiveId(); + this.senderNickname = messageResponse.getSenderNickname(); + this.type = messageResponse.getType(); + this.content = messageResponse.getContent(); + this.createdAt = LocalDateTime.now(); + this.isRead = messageResponse.getIsRead(); + } +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/message/MessageRequest.java b/src/main/java/capstone/facefriend/chat/service/dto/message/MessageRequest.java new file mode 100644 index 0000000000..727a867e7e --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/message/MessageRequest.java @@ -0,0 +1,14 @@ +package capstone.facefriend.chat.service.dto.message; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +@Data +public class MessageRequest { + private Long roomId; + + private Long receiveId; + + private String content; +} \ No newline at end of file diff --git a/src/main/java/capstone/facefriend/chat/service/dto/message/MessageResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/message/MessageResponse.java new file mode 100644 index 0000000000..cb55138300 --- /dev/null +++ b/src/main/java/capstone/facefriend/chat/service/dto/message/MessageResponse.java @@ -0,0 +1,25 @@ +package capstone.facefriend.chat.service.dto.message; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.LocalDateTime; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MessageResponse implements Serializable { + private Long roomId; + private Long receiveId; + private Long senderId; + private String content; + private String type; + private String senderNickname; + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "Asia/Seoul") + private LocalDateTime createdAt; + private Boolean isRead; +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000000..92d6385fe5 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,11 @@ +#production에서 실행할 때 +#jasypt: +# encryptor: +# bean: jasyptStringEncryptor +# password: ${ENCRYPT_KEY} + + +# local에서 실행할 때 +spring: + profiles: + active: dev \ No newline at end of file