fix(server): add user id to comment-attachment model (#13113)

close AF-2723



#### PR Dependency Tree


* **PR #13113** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Comment attachments now track and display the user who uploaded them.

* **Tests**
* Updated tests to verify that the uploader’s information is correctly
stored and retrieved with comment attachments.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fengmk2
2025-07-09 20:16:09 +08:00
committed by GitHub
parent d4c905600b
commit 45c016af8b
6 changed files with 26 additions and 10 deletions
@@ -13,6 +13,7 @@ test.after.always(async () => {
test('should upsert comment attachment', async t => {
const workspace = await module.create(Mockers.Workspace);
const user = await module.create(Mockers.User);
// add
const item = await models.commentAttachment.upsert({
@@ -22,6 +23,7 @@ test('should upsert comment attachment', async t => {
name: 'test-name',
mime: 'text/plain',
size: 100,
createdBy: user.id,
});
t.is(item.workspaceId, workspace.id);
@@ -30,6 +32,7 @@ test('should upsert comment attachment', async t => {
t.is(item.mime, 'text/plain');
t.is(item.size, 100);
t.truthy(item.createdAt);
t.is(item.createdBy, user.id);
// update
const item2 = await models.commentAttachment.upsert({
@@ -46,6 +49,7 @@ test('should upsert comment attachment', async t => {
t.is(item2.key, 'test-key');
t.is(item2.mime, 'text/html');
t.is(item2.size, 200);
t.is(item2.createdBy, user.id);
// make sure only one blob is created
const items = await models.commentAttachment.list(workspace.id);
@@ -32,6 +32,7 @@ export class CommentAttachmentModel extends BaseModel {
name: input.name,
mime: input.mime,
size: input.size,
createdBy: input.createdBy,
},
});
}