Enable routes for chat rooms and use them in missed chat message notification

This commit is contained in:
Maximilian Harz 2025-06-11 11:10:32 +02:00
parent 32927ea96e
commit 0bdc6ecb8f
4 changed files with 59 additions and 5 deletions

View File

@ -159,12 +159,13 @@ export interface ChatMessageEmailInput {
senderUser: UserDbProperties
recipientUser: UserDbProperties
email: string
roomId: string
}
export const sendChatMessageMail = async (
data: ChatMessageEmailInput,
): Promise<OriginalMessage> => {
const { senderUser, recipientUser } = data
const { senderUser, recipientUser, roomId } = data
const to = data.email
try {
const { originalMessage } = await email.send({
@ -178,7 +179,7 @@ export const sendChatMessageMail = async (
name: recipientUser.name,
chattingUser: senderUser.name,
chattingUserUrl: new URL(`/profile/${senderUser.id}/${senderUser.slug}`, CONFIG.CLIENT_URI),
chatUrl: new URL('/chat', CONFIG.CLIENT_URI),
chatUrl: new URL(`/chat/${roomId}`, CONFIG.CLIENT_URI),
},
})
return originalMessage as OriginalMessage

View File

@ -462,6 +462,7 @@ const handleCreateMessage = async (resolve, root, args, context, resolveInfo) =>
})
return {
roomId,
senderUser: await txResponse.records.map((record) => record.get('senderUser'))[0],
recipientUser: await txResponse.records.map((record) => record.get('recipientUser'))[0],
email: await txResponse.records.map((record) => record.get('emailAddress'))[0]?.email,
@ -470,7 +471,7 @@ const handleCreateMessage = async (resolve, root, args, context, resolveInfo) =>
try {
// Execute Query
const { senderUser, recipientUser, email } = await messageRecipient
const { senderUser, recipientUser, email, roomId } = await messageRecipient
if (recipientUser) {
// send subscriptions
@ -487,7 +488,7 @@ const handleCreateMessage = async (resolve, root, args, context, resolveInfo) =>
// Send EMail if we found a user(not blocked) and he is not considered online
if (recipientUser.emailNotificationsChatMessage !== false && !isUserOnline(recipientUser)) {
void sendChatMessageMail({ email, senderUser, recipientUser })
void sendChatMessageMail({ email, senderUser, recipientUser, roomId })
}
}

View File

@ -0,0 +1,52 @@
<template>
<div>
<add-chat-room-by-user-search
v-if="showUserSearch"
@add-chat-room="addChatRoom"
@close-user-search="showUserSearch = false"
/>
<chat
:roomId="getShowChat.showChat ? getShowChat.roomID : this.$route.params.roomId"
ref="chat"
@toggle-user-search="showUserSearch = !showUserSearch"
:show-room="showRoom"
/>
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import AddChatRoomByUserSearch from '~/components/Chat/AddChatRoomByUserSearch'
import Chat from '~/components/Chat/Chat.vue'
export default {
components: {
AddChatRoomByUserSearch,
Chat,
},
data() {
return {
showUserSearch: false,
}
},
mounted() {
this.showChat({ showChat: false, roomID: null })
},
computed: {
...mapGetters({
getShowChat: 'chat/showChat',
}),
},
methods: {
...mapMutations({
showChat: 'chat/SET_OPEN_CHAT',
}),
addChatRoom(userID) {
this.$refs.chat.newRoom(userID)
},
showRoom(roomId) {
this.showChat({ showChat: true, roomID: roomId })
},
},
}
</script>

View File

@ -19,7 +19,7 @@
<script>
import { mapGetters, mapMutations } from 'vuex'
import AddChatRoomByUserSearch from '~/components/Chat/AddChatRoomByUserSearch'
import Chat from '../components/Chat/Chat.vue'
import Chat from '~/components/Chat/Chat.vue'
export default {
components: {