diff --git a/backend/src/api/stories/StoriesController.ts b/backend/src/api/stories/StoriesController.ts index 2934e8d0..44e8111b 100644 --- a/backend/src/api/stories/StoriesController.ts +++ b/backend/src/api/stories/StoriesController.ts @@ -44,6 +44,8 @@ import { } from './storyToApi'; import EmailCampaignService from '../../business/email/EmailCampaignService'; import normalizeEmail from '../../business/utils/normalizeEmail'; +import { UserData as NetlifyUserData } from 'gotrue-js'; +import required from '../../business/utils/required'; function updateModelFromRequest( story: Story, @@ -238,7 +240,8 @@ export class StoriesController extends Controller { @Patch('/{id}/state') public async updateStoryState( @Path('id') id: number, - @Body() updates: { state: StoryState } + @Body() updates: { state: StoryState }, + @Request() req: Express.Request & { user?: NetlifyUserData } ): Promise { let story = await StoryRepository().findOneBy({ id }); @@ -259,6 +262,7 @@ export class StoriesController extends Controller { } story.state = updates.state; + story.lastReviewer = required(req.user, 'user').email; story = await StoryRepository().save(story); diff --git a/backend/src/entities/Story.ts b/backend/src/entities/Story.ts index 290513c8..d11386b1 100644 --- a/backend/src/entities/Story.ts +++ b/backend/src/entities/Story.ts @@ -86,4 +86,7 @@ export default class Story { @Column() hasEverSubmitted: boolean; + + @Column() + lastReviewer!: string | null; }