mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-01 00:08:31 +09:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
3248529d59
@ -34,6 +34,7 @@
|
||||
- 타임라인 소개 추가
|
||||
- 이용 약관을 서버 메뉴에서 볼 수 있도록
|
||||
- 계정 초기 설정과 타임라인 튜토리얼을 다시 진행할 수 있도록
|
||||
- 리모트 사용자의 노트/팔로잉/팔로워 수를 리모트 서버의 정보와 동일하게 보이도록
|
||||
- 유저 메뉴에서 '리모트 유저 정보 갱신'을 진행할 수 있도록
|
||||
- 설정에서 변경 가능한 옵션은 다이얼로그에서 안내하도록 주석 추가
|
||||
|
||||
|
@ -279,6 +279,51 @@ export class ApPersonService implements OnModuleInit {
|
||||
throw new Error('unexpected schema of person url: ' + url);
|
||||
}
|
||||
|
||||
let followersCount: number | undefined;
|
||||
|
||||
if (typeof person.followers === 'string') {
|
||||
try {
|
||||
const data = await fetch(person.followers, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const jsonData = JSON.parse(await data.text());
|
||||
|
||||
followersCount = jsonData.totalItems;
|
||||
} catch {
|
||||
followersCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let followingCount: number | undefined;
|
||||
|
||||
if (typeof person.following === 'string') {
|
||||
try {
|
||||
const data = await fetch(person.following, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const jsonData = JSON.parse(await data.text());
|
||||
|
||||
followingCount = jsonData.totalItems;
|
||||
} catch (e) {
|
||||
followingCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let notesCount: number | undefined;
|
||||
|
||||
if (typeof person.outbox === 'string') {
|
||||
try {
|
||||
const data = await fetch(person.outbox, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const jsonData = JSON.parse(await data.text());
|
||||
|
||||
notesCount = jsonData.totalItems;
|
||||
} catch (e) {
|
||||
notesCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Create user
|
||||
let user: MiRemoteUser | null = null;
|
||||
|
||||
@ -312,6 +357,30 @@ export class ApPersonService implements OnModuleInit {
|
||||
inbox: person.inbox,
|
||||
sharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox,
|
||||
followersUri: person.followers ? getApId(person.followers) : undefined,
|
||||
followersCount:
|
||||
followersCount !== undefined
|
||||
? followersCount
|
||||
: person.followers &&
|
||||
typeof person.followers !== 'string' &&
|
||||
isCollectionOrOrderedCollection(person.followers)
|
||||
? person.followers.totalItems
|
||||
: undefined,
|
||||
followingCount:
|
||||
followingCount !== undefined
|
||||
? followingCount
|
||||
: person.following &&
|
||||
typeof person.following !== 'string' &&
|
||||
isCollectionOrOrderedCollection(person.following)
|
||||
? person.following.totalItems
|
||||
: undefined,
|
||||
notesCount:
|
||||
notesCount !== undefined
|
||||
? notesCount
|
||||
: person.outbox &&
|
||||
typeof person.outbox !== 'string' &&
|
||||
isCollectionOrOrderedCollection(person.outbox)
|
||||
? person.outbox.totalItems
|
||||
: undefined,
|
||||
featured: person.featured ? getApId(person.featured) : undefined,
|
||||
uri: person.id,
|
||||
tags,
|
||||
@ -440,11 +509,80 @@ export class ApPersonService implements OnModuleInit {
|
||||
throw new Error('unexpected schema of person url: ' + url);
|
||||
}
|
||||
|
||||
let followersCount: number | undefined;
|
||||
|
||||
if (typeof person.followers === 'string') {
|
||||
try {
|
||||
const data = await fetch(person.followers, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const jsonData = JSON.parse(await data.text());
|
||||
|
||||
followersCount = jsonData.totalItems;
|
||||
} catch {
|
||||
followersCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let followingCount: number | undefined;
|
||||
|
||||
if (typeof person.following === 'string') {
|
||||
try {
|
||||
const data = await fetch(person.following, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const jsonData = JSON.parse(await data.text());
|
||||
|
||||
followingCount = jsonData.totalItems;
|
||||
} catch {
|
||||
followingCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let notesCount: number | undefined;
|
||||
|
||||
if (typeof person.outbox === 'string') {
|
||||
try {
|
||||
const data = await fetch(person.outbox, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const jsonData = JSON.parse(await data.text());
|
||||
|
||||
notesCount = jsonData.totalItems;
|
||||
} catch (e) {
|
||||
notesCount = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const updates = {
|
||||
lastFetchedAt: new Date(),
|
||||
inbox: person.inbox,
|
||||
sharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox,
|
||||
followersUri: person.followers ? getApId(person.followers) : undefined,
|
||||
followersCount:
|
||||
followersCount !== undefined
|
||||
? followersCount
|
||||
: person.followers &&
|
||||
typeof person.followers !== 'string' &&
|
||||
isCollectionOrOrderedCollection(person.followers)
|
||||
? person.followers.totalItems
|
||||
: undefined,
|
||||
followingCount:
|
||||
followingCount !== undefined
|
||||
? followingCount
|
||||
: person.following &&
|
||||
typeof person.following !== 'string' &&
|
||||
isCollectionOrOrderedCollection(person.following)
|
||||
? person.following.totalItems
|
||||
: undefined,
|
||||
notesCount:
|
||||
notesCount !== undefined
|
||||
? notesCount
|
||||
: person.outbox &&
|
||||
typeof person.outbox !== 'string' &&
|
||||
isCollectionOrOrderedCollection(person.outbox)
|
||||
? person.outbox.totalItems
|
||||
: undefined,
|
||||
featured: person.featured,
|
||||
emojis: emojiNames,
|
||||
name: truncate(person.name, nameLength),
|
||||
@ -587,7 +725,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
|
||||
// Resolve to Object(may be Note) arrays
|
||||
const unresolvedItems = isCollection(collection) ? collection.items : collection.orderedItems;
|
||||
const items = await Promise.all(toArray(unresolvedItems).map(x => _resolver.resolve(x)));
|
||||
const items = await Promise.all(toArray(unresolvedItems).map(x => _resolver?.resolve(x)));
|
||||
|
||||
// Resolve and regist Notes
|
||||
const limit = promiseLimit<MiNote | null>(2);
|
||||
|
@ -421,8 +421,8 @@ export class UserEntityService implements OnModuleInit {
|
||||
birthday: profile!.birthday,
|
||||
lang: profile!.lang,
|
||||
fields: profile!.fields,
|
||||
followersCount: followersCount ?? 0,
|
||||
followingCount: followingCount ?? 0,
|
||||
followersCount: followersCount ?? '?',
|
||||
followingCount: followingCount ?? '?',
|
||||
notesCount: user.notesCount,
|
||||
pinnedNoteIds: pins.map(pin => pin.noteId),
|
||||
pinnedNotes: this.noteEntityService.packMany(pins.map(pin => pin.note!), me, {
|
||||
|
Loading…
Reference in New Issue
Block a user