Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-mayflies-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Includes attachments metadata in JSON export if type is file when exporting messages
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ import { Messages } from '../../../../../app/models/client';
import { downloadJsonAs } from '../../../../lib/download';
import { useRoom } from '../../contexts/RoomContext';

const messagesFields: FindOptions<IMessage> = { projection: { _id: 1, ts: 1, u: 1, msg: 1, _updatedAt: 1, tlm: 1, replies: 1, tmid: 1 } };
const messagesFields: FindOptions<IMessage> = {
projection: {
'_id': 1,
'ts': 1,
'u': 1,
'msg': 1,
'_updatedAt': 1,
'tlm': 1,
'replies': 1,
'tmid': 1,
'attachments.ts': 1,
'attachments.title': 1,
'attachments.title_link': 1,
'attachments.title_link_download': 1,
'attachments.image_dimensions': 1,
'attachments.image_preview': 1,
'attachments.image_url': 1,
'attachments.image_type': 1,
'attachments.image_size': 1,
'attachments.type': 1,
'attachments.description': 1,
},
};

export const useDownloadExportMutation = () => {
const { t } = useTranslation();
Expand All @@ -20,7 +42,28 @@ export const useDownloadExportMutation = () => {
mutationFn: async ({ mids }: { mids: IMessage['_id'][] }) => {
const messages = Messages.find(
{
$or: [{ _id: { $in: mids } }, { tmid: { $in: mids } }],
$and: [
{
$or: [{ _id: { $in: mids } }, { tmid: { $in: mids } }],
},
{
$or: [
{
attachments: {
$exists: true,
$elemMatch: {
type: 'file',
},
},
},
{
attachments: {
$exists: false,
},
},
],
},
],
},
messagesFields,
).fetch();
Expand Down
Loading