fix: services use the new typings from create methods

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-09-25 11:52:42 +02:00 committed by David Mehren
parent d0b8e4cd36
commit 8cda5f99fb
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
4 changed files with 15 additions and 11 deletions

View file

@ -79,17 +79,17 @@ export class AuthService {
new Date().getTime() + 2 * 365 * 24 * 60 * 60 * 1000;
if (validUntil === 0 || validUntil > maximumTokenValidity) {
token = AuthToken.create(
keyId,
user,
identifier,
keyId,
accessToken,
new Date(maximumTokenValidity),
);
} else {
token = AuthToken.create(
keyId,
user,
identifier,
keyId,
accessToken,
new Date(validUntil),
);

View file

@ -173,7 +173,7 @@ export class HistoryService {
`Note with id/alias '${historyEntry.note}' not found.`,
);
}
const entry = HistoryEntry.create(user, note);
const entry = HistoryEntry.create(user, note) as HistoryEntry;
entry.pinStatus = historyEntry.pinStatus;
entry.updatedAt = historyEntry.lastVisited;
await manager.save<HistoryEntry>(entry);

View file

@ -61,17 +61,17 @@ export class AliasService {
`The alias '${alias}' is already a public id.`,
);
}
let newAlias: Alias;
let newAlias;
if (note.aliases.length === 0) {
// the first alias is automatically made the primary alias
newAlias = Alias.create(alias, true);
newAlias = Alias.create(alias, note, true);
} else {
newAlias = Alias.create(alias);
newAlias = Alias.create(alias, note);
}
note.aliases.push(newAlias);
note.aliases.push(newAlias as Alias);
await this.noteRepository.save(note);
return newAlias;
return newAlias as Alias;
}
/**

View file

@ -97,10 +97,12 @@ export class NotesService {
const newNote = Note.create(owner, alias);
//TODO: Calculate patch
newNote.revisions = Promise.resolve([
Revision.create(noteContent, noteContent),
Revision.create(noteContent, noteContent, newNote as Note) as Revision,
]);
if (owner) {
newNote.historyEntries = [HistoryEntry.create(owner)];
newNote.historyEntries = [
HistoryEntry.create(owner, newNote as Note) as HistoryEntry,
];
}
try {
return await this.noteRepository.save(newNote);
@ -258,7 +260,7 @@ export class NotesService {
async updateNote(note: Note, noteContent: string): Promise<Note> {
const revisions = await note.revisions;
//TODO: Calculate patch
revisions.push(Revision.create(noteContent, noteContent));
revisions.push(Revision.create(noteContent, noteContent, note) as Revision);
note.revisions = Promise.resolve(revisions);
note.userPermissions = [];
note.groupPermissions = [];
@ -306,6 +308,7 @@ export class NotesService {
);
const createdPermission = NoteUserPermission.create(
user,
note,
newUserPermission.canEdit,
);
createdPermission.note = note;
@ -319,6 +322,7 @@ export class NotesService {
);
const createdPermission = NoteGroupPermission.create(
group,
note,
newGroupPermission.canEdit,
);
createdPermission.note = note;