From dfd9bd5dd106f27fc6dde09d80d40c07116ae517 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 9 Jul 2023 20:12:13 -0700 Subject: [PATCH] Revert "[mastodon-client] send proper user preferences" This reverts commit 3fe156f79578d8506cfbb70f3f6f806f50a818b9. --- packages/megalodon/src/misskey.ts | 24 +++++++++++++++----- packages/megalodon/src/misskey/api_client.ts | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/megalodon/src/misskey.ts b/packages/megalodon/src/misskey.ts index 026b8e9b7a..b4a9c6adb9 100644 --- a/packages/megalodon/src/misskey.ts +++ b/packages/megalodon/src/misskey.ts @@ -1079,11 +1079,23 @@ export default class Misskey implements MegalodonInterface { // accounts/preferences // ====================================== public async getPreferences(): Promise> { - return this.client.post('/api/i').then(async res => { - return Object.assign(res, { - data: this.converter.userPreferences(res.data, await this.getDefaultPostPrivacy()) - }) - }) + return this.client.post('/api/i').then(res => { + /* + return this.client.post('/api/i/registry/get-all', { + scope: ['client', 'base'], + }).then(ga => { + return Object.assign(res, { + data: this.converter.userPreferences(res.data, ga.data) + }) + }) + */ + + // TODO: + // FIXME: get this from api + return Object.assign(res, { + data: this.converter.userPreferences(res.data, {defaultNoteVisibility: "followers", tutorial: -1}) + }) + }) } // ====================================== @@ -1527,7 +1539,7 @@ export default class Misskey implements MegalodonInterface { .then(res => res.data[0] ?? '⭐'); } - private async getDefaultPostPrivacy(): Promise<'public' | 'unlisted' | 'private' | 'direct'> { + private async getDefaultPostPrivacy(): Promise { // NOTE: get-unsecure is calckey's extension. // Misskey doesn't have this endpoint and regular `/i/registry/get` won't work // unless you have a 'nativeToken', which is reserved for the frontend webapp. diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index f80d5a4421..aabb1f3ee5 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -175,13 +175,13 @@ namespace MisskeyAPI { } } - userPreferences = (u: MisskeyAPI.Entity.UserDetailMe, v: 'public' | 'unlisted' | 'private' | 'direct'): MegalodonEntity.Preferences => { + userPreferences = (u: MisskeyAPI.Entity.UserDetailMe, g: MisskeyAPI.Entity.GetAll): MegalodonEntity.Preferences => { return { "reading:expand:media": "default", "reading:expand:spoilers": false, "posting:default:language": u.lang, "posting:default:sensitive": u.alwaysMarkNsfw, - "posting:default:visibility": v + "posting:default:visibility": this.visibility(g.defaultNoteVisibility) } }