Move profile-related functions into PhotoProfile

The previous Profile type was renamed to PassportProfile, as it is only used for profile-information from Passport plugins.
All functions relating to profile-parsing are now encapsulated in the PhotoProfile class (naming still debatable).

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2020-06-04 21:25:42 +02:00
parent 4552085ae0
commit 4e7c82dc3b
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB
5 changed files with 84 additions and 92 deletions

View file

@ -6,6 +6,7 @@ import { config } from '../../config'
import { errors } from '../../errors'
import { logger } from '../../logger'
import { Note, User } from '../../models'
import { PassportProfile, PhotoProfile } from '../../models/user'
export function newNote (req, res: Response, body: string | null): void {
let owner = null
@ -96,9 +97,9 @@ export function getPublishData (req: Request, res: Response, note, callback: (da
theme: meta.slideOptions && isRevealTheme(meta.slideOptions.theme),
meta: JSON.stringify(extracted.meta),
owner: note.owner ? note.owner.id : null,
ownerprofile: note.owner ? User.getProfile(note.owner) : null,
ownerprofile: note.owner ? PhotoProfile.fromUser(note.owner) : null,
lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null,
lastchangeuserprofile: note.lastchangeuser ? User.getProfile(note.lastchangeuser) : null,
lastchangeuserprofile: note.lastchangeuser ? PhotoProfile.fromUser(note.lastchangeuser) : null,
robots: meta.robots || false, // default allow robots
GA: meta.GA,
disqus: meta.disqus,