mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
Rename Authorship entity to Edit
As we now have a separate Author entity, which holds information about an author (the color), the Authorship name became confusing. Edit seems to be a better name, as the entity saves information about a change in a note. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
2b0fa17d03
commit
62e0530d2b
19 changed files with 67 additions and 73 deletions
|
@ -26,7 +26,7 @@ export class NoteDto {
|
|||
metadata: NoteMetadataDto;
|
||||
|
||||
/**
|
||||
* Authorship information of this note
|
||||
* Edit information of this note
|
||||
*/
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
|
|
|
@ -8,7 +8,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
|||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import { Author } from '../authors/author.entity';
|
||||
import { LoggerModule } from '../logger/logger.module';
|
||||
import { Authorship } from '../revisions/authorship.entity';
|
||||
import { Edit } from '../revisions/edit.entity';
|
||||
import { Revision } from '../revisions/revision.entity';
|
||||
import { RevisionsModule } from '../revisions/revisions.module';
|
||||
import { AuthToken } from '../auth/auth-token.entity';
|
||||
|
@ -89,7 +89,7 @@ describe('NotesService', () => {
|
|||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Identity))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Authorship))
|
||||
.overrideProvider(getRepositoryToken(Edit))
|
||||
.useValue({})
|
||||
.overrideProvider(getRepositoryToken(Revision))
|
||||
.useClass(Repository)
|
||||
|
@ -680,21 +680,21 @@ describe('NotesService', () => {
|
|||
.mockImplementation(async (note: Note): Promise<Note> => note);
|
||||
const note = await service.createNote(content);
|
||||
const revisions = await note.revisions;
|
||||
revisions[0].authorships = [
|
||||
revisions[0].edits = [
|
||||
{
|
||||
revisions: revisions,
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452000),
|
||||
author: author,
|
||||
} as Authorship,
|
||||
} as Edit,
|
||||
{
|
||||
revisions: revisions,
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452001),
|
||||
author: author,
|
||||
} as Authorship,
|
||||
} as Edit,
|
||||
];
|
||||
revisions[0].createdAt = new Date(1549312452000);
|
||||
jest.spyOn(revisionRepo, 'findOne').mockResolvedValue(revisions[0]);
|
||||
|
@ -776,21 +776,21 @@ describe('NotesService', () => {
|
|||
.mockImplementation(async (note: Note): Promise<Note> => note);
|
||||
const note = await service.createNote(content);
|
||||
const revisions = await note.revisions;
|
||||
revisions[0].authorships = [
|
||||
revisions[0].edits = [
|
||||
{
|
||||
revisions: revisions,
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452000),
|
||||
author: author,
|
||||
} as Authorship,
|
||||
} as Edit,
|
||||
{
|
||||
revisions: revisions,
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452001),
|
||||
author: author,
|
||||
} as Authorship,
|
||||
} as Edit,
|
||||
];
|
||||
revisions[0].createdAt = new Date(1549312452000);
|
||||
jest
|
||||
|
|
|
@ -198,8 +198,8 @@ export class NotesService {
|
|||
return await this.userRepository
|
||||
.createQueryBuilder('user')
|
||||
.innerJoin('user.authors', 'author')
|
||||
.innerJoin('author.authorships', 'authorship')
|
||||
.innerJoin('authorship.revisions', 'revision')
|
||||
.innerJoin('author.edits', 'edit')
|
||||
.innerJoin('edit.revisions', 'revision')
|
||||
.innerJoin('revision.note', 'note')
|
||||
.where('note.id = :id', { id: note.id })
|
||||
.getMany();
|
||||
|
@ -322,14 +322,14 @@ export class NotesService {
|
|||
*/
|
||||
async calculateUpdateUser(note: Note): Promise<User | null> {
|
||||
const lastRevision = await this.getLatestRevision(note);
|
||||
if (lastRevision && lastRevision.authorships) {
|
||||
// Sort the last Revisions Authorships by their updatedAt Date to get the latest one
|
||||
// the user of that Authorship is the updateUser
|
||||
return lastRevision.authorships.sort(
|
||||
if (lastRevision && lastRevision.edits) {
|
||||
// Sort the last Revisions Edits by their updatedAt Date to get the latest one
|
||||
// the user of that Edit is the updateUser
|
||||
return lastRevision.edits.sort(
|
||||
(a, b) => b.updatedAt.getTime() - a.updatedAt.getTime(),
|
||||
)[0].author.user;
|
||||
}
|
||||
// If there are no Authorships, the owner is the updateUser
|
||||
// If there are no Edits, the owner is the updateUser
|
||||
return note.owner;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue