Revert "Revert "[mastodon-client] send proper user preferences""

This reverts commit dfd9bd5dd1.
This commit is contained in:
Laura Hausmann 2023-07-10 18:50:12 +02:00
parent 3e1b112f92
commit dc0194a842
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 8 additions and 20 deletions

View File

@ -1079,23 +1079,11 @@ export default class Misskey implements MegalodonInterface {
// accounts/preferences
// ======================================
public async getPreferences(): Promise<Response<Entity.Preferences>> {
return this.client.post<MisskeyAPI.Entity.UserDetailMe>('/api/i').then(res => {
/*
return this.client.post<MisskeyAPI.Entity.GetAll>('/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})
})
})
return this.client.post<MisskeyAPI.Entity.UserDetailMe>('/api/i').then(async res => {
return Object.assign(res, {
data: this.converter.userPreferences(res.data, await this.getDefaultPostPrivacy())
})
})
}
// ======================================
@ -1539,7 +1527,7 @@ export default class Misskey implements MegalodonInterface {
.then(res => res.data[0] ?? '⭐');
}
private async getDefaultPostPrivacy(): Promise<string> {
private async getDefaultPostPrivacy(): Promise<'public' | 'unlisted' | 'private' | 'direct'> {
// 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.

View File

@ -175,13 +175,13 @@ namespace MisskeyAPI {
}
}
userPreferences = (u: MisskeyAPI.Entity.UserDetailMe, g: MisskeyAPI.Entity.GetAll): MegalodonEntity.Preferences => {
userPreferences = (u: MisskeyAPI.Entity.UserDetailMe, v: 'public' | 'unlisted' | 'private' | 'direct'): MegalodonEntity.Preferences => {
return {
"reading:expand:media": "default",
"reading:expand:spoilers": false,
"posting:default:language": u.lang,
"posting:default:sensitive": u.alwaysMarkNsfw,
"posting:default:visibility": this.visibility(g.defaultNoteVisibility)
"posting:default:visibility": v
}
}