mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
including a new voice message attachment type
- allows for us to explictly delete voice message after uploading rather than inferring that audio message with the .ogg extension are voice messages which could have caused us to delete users files
This commit is contained in:
parent
72bc442fca
commit
5ee379e10d
5 changed files with 11 additions and 9 deletions
|
@ -44,7 +44,8 @@ data class ContentAttachmentData(
|
|||
FILE,
|
||||
IMAGE,
|
||||
AUDIO,
|
||||
VIDEO
|
||||
VIDEO,
|
||||
VOICE_MESSAGE
|
||||
}
|
||||
|
||||
fun getSafeMimeType() = mimeType?.normalizeMimeType()
|
||||
|
|
|
@ -280,7 +280,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||
}
|
||||
|
||||
// Delete the temporary voice message file
|
||||
if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) {
|
||||
if (params.attachment.type == ContentAttachmentData.Type.VOICE_MESSAGE) {
|
||||
context.contentResolver.delete(params.attachment.queryUri, null, null)
|
||||
}
|
||||
|
||||
|
|
|
@ -205,10 +205,11 @@ internal class LocalEchoEventFactory @Inject constructor(
|
|||
|
||||
fun createMediaEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
||||
return when (attachment.type) {
|
||||
ContentAttachmentData.Type.IMAGE -> createImageEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.VIDEO -> createVideoEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.AUDIO -> createAudioEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.IMAGE -> createImageEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.VIDEO -> createVideoEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.AUDIO -> createAudioEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.VOICE_MESSAGE -> createAudioEvent(roomId, attachment)
|
||||
ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,11 @@ fun MultiPickerFileType.toContentAttachmentData(): ContentAttachmentData {
|
|||
)
|
||||
}
|
||||
|
||||
fun MultiPickerAudioType.toContentAttachmentData(): ContentAttachmentData {
|
||||
fun MultiPickerAudioType.toContentAttachmentData(isVoiceMessage: Boolean): ContentAttachmentData {
|
||||
if (mimeType == null) Timber.w("No mimeType")
|
||||
return ContentAttachmentData(
|
||||
mimeType = mimeType,
|
||||
type = mapType(),
|
||||
type = if (isVoiceMessage) ContentAttachmentData.Type.VOICE_MESSAGE else mapType(),
|
||||
size = size,
|
||||
name = displayName,
|
||||
duration = duration,
|
||||
|
|
|
@ -714,7 +714,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||
} else {
|
||||
voiceMessageHelper.stopRecording()?.let { audioType ->
|
||||
if (audioType.duration > 1000) {
|
||||
room.sendMedia(audioType.toContentAttachmentData(), false, emptySet())
|
||||
room.sendMedia(audioType.toContentAttachmentData(isVoiceMessage = true), false, emptySet())
|
||||
} else {
|
||||
voiceMessageHelper.deleteRecording()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue