Files
wekan/server/lib/tests/attachmentDeleteActor.tests.js
Lauri OjansivuandClaude Opus 4.8 2ba8882d88 Fix #5504: deleted-attachment notification credits the deleter
The deleteAttachment activity used fileObj.userId (the uploader) instead of the
user who deleted the attachment, so notifications/history named the wrong person.
Record the acting user (Meteor.userId()) for the delete activity, falling back to
the uploader for server/system removals. Upload activity is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 17:45:43 +03:00

25 lines
1017 B
JavaScript

/* eslint-env mocha */
import { expect } from 'chai';
import { deleteActivityUserId } from '../attachmentActivityActor';
// Bug #5504: the 'deleteAttachment' activity must credit the user who actually
// deleted the attachment (the acting user), not the original uploader.
describe('attachmentActivityActor.deleteActivityUserId', function() {
it('credits the acting user when an acting user is present', function() {
const actingUserId = 'acting-user-deleter';
const uploaderUserId = 'uploader-person-a';
expect(deleteActivityUserId(actingUserId, uploaderUserId)).to.equal(
actingUserId,
);
});
it('falls back to the uploader when there is no acting user', function() {
const uploaderUserId = 'uploader-person-a';
expect(deleteActivityUserId(null, uploaderUserId)).to.equal(uploaderUserId);
expect(deleteActivityUserId(undefined, uploaderUserId)).to.equal(
uploaderUserId,
);
expect(deleteActivityUserId('', uploaderUserId)).to.equal(uploaderUserId);
});
});