diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-10 15:04:27 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-10 15:04:27 +0900 |
| commit | 626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c (patch) | |
| tree | 23b89c000b1b169c36cffc7a345a2fc1ebe33347 /src/remote | |
| parent | Delete get-user-summary.ts (diff) | |
| download | misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.tar.gz misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.tar.bz2 misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.zip | |
テーブル分割
Diffstat (limited to 'src/remote')
| -rw-r--r-- | src/remote/activitypub/models/person.ts | 23 | ||||
| -rw-r--r-- | src/remote/activitypub/renderer/person.ts | 26 |
2 files changed, 23 insertions, 26 deletions
diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 6129dad3d3..a6f7482bba 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -14,16 +14,16 @@ import { IIdentifier } from './identifier'; import { apLogger } from '../logger'; import { Note } from '../../../models/entities/note'; import { updateHashtag } from '../../../services/update-hashtag'; -import { Users, UserNotePinings, Instances, DriveFiles, Followings, UserServiceLinkings, UserPublickeys } from '../../../models'; +import { Users, UserNotePinings, Instances, DriveFiles, Followings, UserProfiles, UserPublickeys } from '../../../models'; import { User, IRemoteUser } from '../../../models/entities/user'; import { Emoji } from '../../../models/entities/emoji'; import { UserNotePining } from '../../../models/entities/user-note-pinings'; import { genId } from '../../../misc/gen-id'; -import { UserServiceLinking } from '../../../models/entities/user-service-linking'; import { instanceChart, usersChart } from '../../../services/chart'; import { UserPublickey } from '../../../models/entities/user-publickey'; import { isDuplicateKeyValueError } from '../../../misc/is-duplicate-key-value-error'; import { toPuny } from '../../../misc/convert-host'; +import { UserProfile } from '../../../models/entities/user-profile'; const logger = apLogger; /** @@ -126,7 +126,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us const host = toPuny(new URL(object.id).hostname); - const { fields, services } = analyzeAttachments(person.attachment); + const { fields } = analyzeAttachments(person.attachment); const tags = extractHashtags(person.tag).map(tag => tag.toLowerCase()); @@ -141,7 +141,6 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us bannerId: null, createdAt: Date.parse(person.published) || new Date(), lastFetchedAt: new Date(), - description: fromHtml(person.summary), name: person.name, isLocked: person.manuallyApprovesFollowers, username: person.preferredUsername, @@ -153,8 +152,6 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us endpoints: person.endpoints, uri: person.id, url: person.url, - fields, - ...services, tags, isBot, isCat: (person as any).isCat === true @@ -169,18 +166,18 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us throw e; } + await UserProfiles.save({ + userId: user.id, + description: fromHtml(person.summary), + fields, + } as Partial<UserProfile>); + await UserPublickeys.save({ - id: genId(), userId: user.id, keyId: person.publicKey.id, keyPem: person.publicKey.publicKeyPem } as UserPublickey); - await UserServiceLinkings.save({ - id: genId(), - userId: user.id - } as UserServiceLinking); - // Register host registerOrFetchInstanceDoc(host).then(i => { Instances.increment({ id: i.id }, 'usersCount', 1); @@ -347,7 +344,7 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje keyPem: person.publicKey.publicKeyPem }); - await UserServiceLinkings.update({ userId: exist.id }, { + await UserProfiles.update({ userId: exist.id }, { twitterUserId: services.twitter.userId, twitterScreenName: services.twitter.screenName, githubId: services.github.id, diff --git a/src/remote/activitypub/renderer/person.ts b/src/remote/activitypub/renderer/person.ts index 4c6b518eb6..e561e47c68 100644 --- a/src/remote/activitypub/renderer/person.ts +++ b/src/remote/activitypub/renderer/person.ts @@ -8,15 +8,15 @@ import { getEmojis } from './note'; import renderEmoji from './emoji'; import { IIdentifier } from '../models/identifier'; import renderHashtag from './hashtag'; -import { DriveFiles, UserServiceLinkings, UserKeypairs } from '../../../models'; +import { DriveFiles, UserProfiles, UserKeypairs } from '../../../models'; export async function renderPerson(user: ILocalUser) { const id = `${config.url}/users/${user.id}`; - const [avatar, banner, links] = await Promise.all([ + const [avatar, banner, profile] = await Promise.all([ DriveFiles.findOne(user.avatarId), DriveFiles.findOne(user.bannerId), - UserServiceLinkings.findOne({ userId: user.id }) + UserProfiles.findOne({ userId: user.id }) ]); const attachment: { @@ -27,41 +27,41 @@ export async function renderPerson(user: ILocalUser) { identifier?: IIdentifier }[] = []; - if (links.twitter) { + if (profile.twitter) { attachment.push({ type: 'PropertyValue', name: 'Twitter', - value: `<a href="https://twitter.com/intent/user?user_id=${links.twitterUserId}" rel="me nofollow noopener" target="_blank"><span>@${links.twitterScreenName}</span></a>`, + value: `<a href="https://twitter.com/intent/user?user_id=${profile.twitterUserId}" rel="me nofollow noopener" target="_blank"><span>@${profile.twitterScreenName}</span></a>`, identifier: { type: 'PropertyValue', name: 'misskey:authentication:twitter', - value: `${links.twitterUserId}@${links.twitterScreenName}` + value: `${profile.twitterUserId}@${profile.twitterScreenName}` } }); } - if (links.github) { + if (profile.github) { attachment.push({ type: 'PropertyValue', name: 'GitHub', - value: `<a href="https://github.com/${links.githubLogin}" rel="me nofollow noopener" target="_blank"><span>@${links.githubLogin}</span></a>`, + value: `<a href="https://github.com/${profile.githubLogin}" rel="me nofollow noopener" target="_blank"><span>@${profile.githubLogin}</span></a>`, identifier: { type: 'PropertyValue', name: 'misskey:authentication:github', - value: `${links.githubId}@${links.githubLogin}` + value: `${profile.githubId}@${profile.githubLogin}` } }); } - if (links.discord) { + if (profile.discord) { attachment.push({ type: 'PropertyValue', name: 'Discord', - value: `<a href="https://discordapp.com/users/${links.discordId}" rel="me nofollow noopener" target="_blank"><span>${links.discordUsername}#${links.discordDiscriminator}</span></a>`, + value: `<a href="https://discordapp.com/users/${profile.discordId}" rel="me nofollow noopener" target="_blank"><span>${profile.discordUsername}#${profile.discordDiscriminator}</span></a>`, identifier: { type: 'PropertyValue', name: 'misskey:authentication:discord', - value: `${links.discordId}@${links.discordUsername}#${links.discordDiscriminator}` + value: `${profile.discordId}@${profile.discordUsername}#${profile.discordDiscriminator}` } }); } @@ -93,7 +93,7 @@ export async function renderPerson(user: ILocalUser) { url: `${config.url}/@${user.username}`, preferredUsername: user.username, name: user.name, - summary: toHtml(parse(user.description)), + summary: toHtml(parse(profile.description)), icon: user.avatarId && renderImage(avatar), image: user.bannerId && renderImage(banner), tag, |