Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Set message editor prop by default on updates #545

Open
wants to merge 1 commit into
base: alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion src/server/accessors/ModifyUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ModifyUpdater implements IModifyUpdater {
public async message(messageId: string, updater: IUser): Promise<IMessageBuilder> {
const msg = await this.bridges.getMessageBridge().doGetById(messageId, this.appId);

return new MessageBuilder(msg);
return new MessageBuilder(msg).setEditor(updater);
}

public async room(roomId: string, updater: IUser): Promise<IRoomBuilder> {
Expand Down Expand Up @@ -60,6 +60,10 @@ export class ModifyUpdater implements IModifyUpdater {
throw new Error('Invalid sender assigned to the message.');
}

if (!result.editor || !result.editor.id) {
throw new Error('Invalid editor assigned to the message.');
}

return this.bridges.getMessageBridge().doUpdate(result, this.appId);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/server/accessors/ModifyUpdater.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export class ModifyUpdaterTestFixture {
msgBd.setSender(TestData.getUser());
Expect(msg.sender).toBeDefined();

await Expect(async () => await mc.finish(msgBd)).toThrowErrorAsync(Error, 'Invalid editor assigned to the message.');
msgBd.setEditor(TestData.getUser());
Expect(msg.editor).toBeDefined();

const msgBriSpy = SpyOn(this.mockMessageBridge, 'doUpdate');
Expect(await mc.finish(msgBd)).not.toBeDefined();
Expect(msgBriSpy).toHaveBeenCalledWith(msg, this.mockAppId);
Expand Down