mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
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>
25 lines
1017 B
JavaScript
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);
|
|
});
|
|
});
|