Skip to content

Commit

Permalink
fix(chat): Also use constants on incoming data detection
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Mar 27, 2024
1 parent 632b7df commit 89e49e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,11 @@ protected function parseMessage(Message $chatMessage): void {
$parsedMessage = '{file}';
$metaData = $parameters['metaData'] ?? [];
if (isset($metaData['messageType'])) {
if ($metaData['messageType'] === 'voice-message') {
if ($metaData['messageType'] === ChatManager::VERB_VOICE_MESSAGE) {
$chatMessage->setMessageType(ChatManager::VERB_VOICE_MESSAGE);
} elseif ($metaData['messageType'] === 'record-audio') {
} elseif ($metaData['messageType'] === ChatManager::VERB_RECORD_AUDIO) {
$chatMessage->setMessageType(ChatManager::VERB_RECORD_AUDIO);
} elseif ($metaData['messageType'] === 'record-video') {
} elseif ($metaData['messageType'] === ChatManager::VERB_RECORD_VIDEO) {
$chatMessage->setMessageType(ChatManager::VERB_RECORD_VIDEO);
} else {
$chatMessage->setMessageType(ChatManager::VERB_MESSAGE);
Expand Down
2 changes: 1 addition & 1 deletion lib/Chat/SystemMessage/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ protected function fixMimeTypeOfVoiceMessage(ShareCreatedEvent|BeforeDuplicateSh
$metaData = json_decode($metaData, true);
$metaData = is_array($metaData) ? $metaData : [];

if (isset($metaData['messageType']) && $metaData['messageType'] === 'voice-message') {
if (isset($metaData['messageType']) && $metaData['messageType'] === ChatManager::VERB_VOICE_MESSAGE) {
if ($share->getNode()->getMimeType() !== 'audio/mpeg'
&& $share->getNode()->getMimeType() !== 'audio/wav') {
unset($metaData['messageType']);
Expand Down
7 changes: 4 additions & 3 deletions lib/Service/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace OCA\Talk\Service;

use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Model\Attachment;
use OCA\Talk\Model\AttachmentMapper;
use OCA\Talk\Room;
Expand Down Expand Up @@ -61,11 +62,11 @@ public function createAttachmentEntry(Room $room, IComment $comment, string $mes
$messageType = $parameters['metaData']['messageType'] ?? '';
$mimetype = $parameters['metaData']['mimeType'] ?? '';

if ($messageType === 'record-audio') {
if ($messageType === ChatManager::VERB_RECORD_AUDIO) {
$attachment->setObjectType(Attachment::TYPE_RECORDING);
} elseif ($messageType === 'record-video') {
} elseif ($messageType === ChatManager::VERB_RECORD_VIDEO) {
$attachment->setObjectType(Attachment::TYPE_RECORDING);
} elseif ($messageType === 'voice-message') {
} elseif ($messageType === ChatManager::VERB_VOICE_MESSAGE) {
$attachment->setObjectType(Attachment::TYPE_VOICE);
} elseif (str_starts_with($mimetype, 'audio/')) {
$attachment->setObjectType(Attachment::TYPE_AUDIO);
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/RecordingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ public function notificationDismiss(Room $room, Participant $participant, int $t

private function getTypeOfShare(string $mimetype): string {
if (str_starts_with($mimetype, 'video/')) {
return 'record-video';
return ChatManager::VERB_RECORD_VIDEO;
}
return 'record-audio';
return ChatManager::VERB_RECORD_AUDIO;
}

public function shareToChat(Room $room, Participant $participant, int $fileId, int $timestamp): void {
Expand Down

0 comments on commit 89e49e4

Please sign in to comment.