Merge branch 'develop' of https://codeberg.org/calckey/calckey into upstream
This commit is contained in:
commit
ed7b30ad7e
5 changed files with 29 additions and 24 deletions
|
@ -83,9 +83,9 @@ NODE_ENV=production pnpm run migrate
|
||||||
cd packages/backend
|
cd packages/backend
|
||||||
|
|
||||||
LINE_NUM="$(npx typeorm migration:show -d ormconfig.js | grep -n uniformThemecolor1652859567549 | cut -d ':' -f 1)"
|
LINE_NUM="$(npx typeorm migration:show -d ormconfig.js | grep -n uniformThemecolor1652859567549 | cut -d ':' -f 1)"
|
||||||
NUM_MIGRATIONS="$(npx typeorm migration:show -d ormconfig.js | tail -n+"$LINE_NUM" | grep '\[X\]' | nl)"
|
NUM_MIGRATIONS="$(npx typeorm migration:show -d ormconfig.js | tail -n+"$LINE_NUM" | grep '\[X\]' | wc -l)"
|
||||||
|
|
||||||
for i in $(seq 1 $NUM_MIGRAIONS); do
|
for i in $(seq 1 $NUM_MIGRATIONS); do
|
||||||
npx typeorm migration:revert -d ormconfig.js
|
npx typeorm migration:revert -d ormconfig.js
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ export const paramDef = {
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export default define(meta, paramDef, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
if (ps.key !== "reactions") return;
|
if (ps.key !== "reactions" && ps.key !== "defaultNoteVisibility") return;
|
||||||
const query = RegistryItems.createQueryBuilder("item")
|
const query = RegistryItems.createQueryBuilder("item")
|
||||||
.where("item.domain IS NULL")
|
.where("item.domain IS NULL")
|
||||||
.andWhere("item.userId = :userId", { userId: user.id })
|
.andWhere("item.userId = :userId", { userId: user.id })
|
||||||
|
|
|
@ -48,7 +48,7 @@ export function apiAccountMastodon(router: Router): void {
|
||||||
acct.source = {
|
acct.source = {
|
||||||
note: acct.note,
|
note: acct.note,
|
||||||
fields: acct.fields,
|
fields: acct.fields,
|
||||||
privacy: "public",
|
privacy: await client.getDefaultPostPrivacy(),
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
language: "",
|
language: "",
|
||||||
};
|
};
|
||||||
|
|
|
@ -1079,23 +1079,11 @@ 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 Object.assign(res, {
|
||||||
return this.client.post<MisskeyAPI.Entity.GetAll>('/api/i/registry/get-all', {
|
data: this.converter.userPreferences(res.data, await this.getDefaultPostPrivacy())
|
||||||
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})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================
|
// ======================================
|
||||||
|
@ -1539,6 +1527,23 @@ export default class Misskey implements MegalodonInterface {
|
||||||
.then(res => res.data[0] ?? '⭐');
|
.then(res => res.data[0] ?? '⭐');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
return this.client
|
||||||
|
.post<string>('/api/i/registry/get-unsecure', {
|
||||||
|
key: 'defaultNoteVisibility',
|
||||||
|
scope: ['client', 'base'],
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (!res.data || (res.data != 'public' && res.data != 'home' && res.data != 'followers' && res.data != 'specified'))
|
||||||
|
return 'public';
|
||||||
|
return this.converter.visibility(res.data);
|
||||||
|
}).catch(_ => 'public')
|
||||||
|
}
|
||||||
|
|
||||||
public async unfavouriteStatus(id: string): Promise<Response<Entity.Status>> {
|
public async unfavouriteStatus(id: string): Promise<Response<Entity.Status>> {
|
||||||
// NOTE: Misskey allows only one reaction per status, so we don't need to care what that emoji was.
|
// NOTE: Misskey allows only one reaction per status, so we don't need to care what that emoji was.
|
||||||
return this.deleteEmojiReaction(id, '');
|
return this.deleteEmojiReaction(id, '');
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace MisskeyAPI {
|
||||||
id: u.id,
|
id: u.id,
|
||||||
username: u.username,
|
username: u.username,
|
||||||
acct: acct,
|
acct: acct,
|
||||||
display_name: u.name,
|
display_name: u.name || u.username,
|
||||||
locked: u.isLocked,
|
locked: u.isLocked,
|
||||||
created_at: u.createdAt,
|
created_at: u.createdAt,
|
||||||
followers_count: u.followersCount,
|
followers_count: u.followersCount,
|
||||||
|
@ -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 {
|
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