mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-12-01 14:27:33 -07:00
[mastodon-client] send proper user preferences
This commit is contained in:
parent
8f7f078f08
commit
c7d031e7ec
2 changed files with 8 additions and 20 deletions
|
@ -1079,21 +1079,9 @@ export default class Misskey implements MegalodonInterface {
|
||||||
// accounts/preferences
|
// accounts/preferences
|
||||||
// ======================================
|
// ======================================
|
||||||
public async getPreferences(): Promise<Response<Entity.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.UserDetailMe>('/api/i').then(async res => {
|
||||||
/*
|
|
||||||
return this.client.post<MisskeyAPI.Entity.GetAll>('/api/i/registry/get-all', {
|
|
||||||
scope: ['client', 'base'],
|
|
||||||
}).then(ga => {
|
|
||||||
return Object.assign(res, {
|
return Object.assign(res, {
|
||||||
data: this.converter.userPreferences(res.data, ga.data)
|
data: this.converter.userPreferences(res.data, await this.getDefaultPostPrivacy())
|
||||||
})
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// FIXME: get this from api
|
|
||||||
return Object.assign(res, {
|
|
||||||
data: this.converter.userPreferences(res.data, {defaultNoteVisibility: "followers", tutorial: -1})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1529,7 +1517,7 @@ export default class Misskey implements MegalodonInterface {
|
||||||
.then(res => res.data[0] ?? '⭐');
|
.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.
|
// NOTE: get-unsecure is calckey's extension.
|
||||||
// Misskey doesn't have this endpoint and regular `/i/registry/get` won't work
|
// 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.
|
// unless you have a 'nativeToken', which is reserved for the frontend webapp.
|
||||||
|
|
|
@ -174,13 +174,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 {
|
return {
|
||||||
"reading:expand:media": "default",
|
"reading:expand:media": "default",
|
||||||
"reading:expand:spoilers": false,
|
"reading:expand:spoilers": false,
|
||||||
"posting:default:language": u.lang,
|
"posting:default:language": u.lang,
|
||||||
"posting:default:sensitive": u.alwaysMarkNsfw,
|
"posting:default:sensitive": u.alwaysMarkNsfw,
|
||||||
"posting:default:visibility": this.visibility(g.defaultNoteVisibility)
|
"posting:default:visibility": v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue