docs: read scope descriptions from locale strings

This commit is contained in:
Johann150 2022-10-19 09:04:45 +02:00 committed by Gitea
parent c5568cfdf3
commit 2f2e6a58a4
3 changed files with 73 additions and 71 deletions

View File

@ -1082,38 +1082,37 @@ _2fa:
\ authentication via hardware security keys that support FIDO2 to further secure\
\ your account."
_permissions:
"read:account": "View your account information"
"write:account": "Edit your account information"
"read:blocks": "View your list of blocked users"
"write:blocks": "Edit your list of blocked users"
"read:drive": "Access your Drive files and folders"
"write:drive": "Edit or delete your Drive files and folders"
"read:favorites": "View your list of favorites"
"write:favorites": "Edit your list of favorites"
"read:following": "View information on who you follow"
"write:following": "Follow or unfollow other accounts"
"read:messaging": "View your chats"
"write:messaging": "Compose or delete chat messages"
"read:mutes": "View your list of muted users"
"write:mutes": "Edit your list of muted users"
"write:notes": "Compose or delete notes"
"read:notifications": "View your notifications"
"write:notifications": "Manage your notifications"
"read:reactions": "View your reactions"
"write:reactions": "Edit your reactions"
"write:votes": "Vote on a poll"
"read:pages": "View your pages"
"write:pages": "Edit or delete your pages"
"read:page-likes": "View your likes on pages"
"write:page-likes": "Edit your likes on pages"
"read:user-groups": "View your user groups"
"write:user-groups": "Edit or delete your user groups"
"read:channels": "View your channels"
"write:channels": "Edit your channels"
"read:gallery": "View your gallery"
"write:gallery": "Edit your gallery"
"read:gallery-likes": "View your list of liked gallery posts"
"write:gallery-likes": "Edit your list of liked gallery posts"
"read:account": "Read account information"
"write:account": "Edit account information"
"read:blocks": "Read which users are blocked"
"write:blocks": "Block and unblock users"
"read:drive": "List files and folders in the drive"
"write:drive": "Create, change and delete files in the drive"
"read:favorites": "List favourited notes"
"write:favorites": "Favorite and unfavorite notes"
"read:following": "List followed and following users"
"write:following": "Follow and unfollow other users"
"read:messaging": "View chat messages and history"
"write:messaging": "Create and delete chat messages"
"read:mutes": "List users which are muted or whose renotes are muted"
"write:mutes": "Mute and unmute users or their renotes"
"write:notes": "Create and delete notes"
"read:notifications": "Read notifications"
"write:notifications": "Mark notifications as read and create custom notifications"
"write:reactions": "Create and delete reactions"
"write:votes": "Vote in polls"
"read:pages": "List and read pages"
"write:pages": "Create, change and delete pages"
"read:page-likes": "List and read page likes"
"write:page-likes": "Like and unlike pages"
"read:user-groups": "List and view joined, owned and invited to groups"
"write:user-groups": "Create, modify, delete, transfer, join and leave groups. Invite and ban others from groups. Accept and reject group invitations."
"read:channels": "List and read followed and joined channels"
"write:channels": "Create, modify, follow and unfollow channels"
"read:gallery": "List and read gallery posts"
"write:gallery": "Create, modify and delete gallery posts"
"read:gallery-likes": "List and read gallery post likes"
"write:gallery-likes": "Like and unlike gallery posts"
_auth:
shareAccess: "Would you like to authorize \"{name}\" to access this account?"
shareAccessAsk: "Are you sure you want to authorize this application to access your\

View File

@ -1,38 +1,35 @@
export const kinds = [
'read:account',
'write:account',
'read:blocks',
'write:blocks',
'read:drive',
'write:drive',
'read:favorites',
'write:favorites',
'read:following',
'write:following',
'read:messaging',
'write:messaging',
'read:mutes',
'write:mutes',
'write:notes',
'read:notifications',
'write:notifications',
'read:reactions',
'write:reactions',
'write:votes',
'read:pages',
'write:pages',
'write:page-likes',
'read:page-likes',
'read:user-groups',
'write:user-groups',
'read:channels',
'write:channels',
'read:gallery',
'write:gallery',
'read:gallery-likes',
'write:gallery-likes',
];
// IF YOU ADD KINDS(PERMISSIONS), YOU MUST ADD TRANSLATIONS (under _permissions).
// short English descriptions used for the documentation
export const descriptions = {
'read:account': 'Read the accounts data.',
'write:account': 'Write the accounts data.',
'read:blocks': 'Read which users are blocked.',
'write:blocks': 'Create, change and delete blocks.',
'read:drive': 'List files and folders in the drive.',
'write:drive': 'Create, change and delete files from the drive.',
'read:favourites': 'List favourited notes.',
'write:favourites': 'Favourite or unfavourite notes.',
'read:following': 'Read who the user is following.',
'write:following': 'Follow or unfollow other users.',
'read:messaging': 'Read chat messages and history.',
'write:messaging': 'Create and delete chat messages.',
'read:mutes': 'List users which are muted or whose renotes are muted.',
'write:mutes': 'Create or delete (renote) mutes.',
'write:notes': 'Create or delete notes.',
'read:notifications': 'Read notifications.',
'write:notifications': 'Mark notifications as read or create notifications.',
'write:reactions': 'Create or delete reactions.',
'write:votes': 'Vote in polls.',
'read:pages': 'List and read pages.',
'write:pages': 'Create, modify and delete pages.',
'read:page-likes': 'List page likes.',
'write:page-likes': 'Like or unlike pages.',
'read:user-groups': 'List joined, owned and invited to groups.',
'write:user-groups': 'Create, modify, delete, transfer, join, or leave groups. Invite or ban others from groups. Accept or reject group invitations.',
'read:channels': 'List followed and owned channels.',
'write:channels': 'Create, modify, follow or unfollow channels.',
'read:gallery': 'Read gallery posts.',
'write:gallery': 'Create, modify or delete gallery posts.',
'read:gallery-likes': 'List which gallery posts are liked.',
'write:gallery-likes': 'Like or unlike gallery posts.',
};
export const kinds = Object.keys(descriptions);

View File

@ -3,7 +3,10 @@ import { errors as errorDefinitions } from '../error.js';
import endpoints from '../endpoints.js';
import { schemas, convertSchemaToOpenApiSchema } from './schemas.js';
import { httpCodes } from './http-codes.js';
import { descriptions as scopes } from '@/misc/api-permissions.js';
import { kinds } from '@/misc/api-permissions.js';
import { I18n } from '@/misc/i18n.js';
const i18n = new I18n('en-US');
export function genOpenapiSpec() {
const spec = {
@ -41,7 +44,10 @@ export function genOpenapiSpec() {
authorizationCode: {
authorizationUrl: `${config.url}/auth`,
tokenUrl: `${config.apiUrl}/auth/session/oauth`,
scopes,
scopes: kinds.reduce((acc, kind) => {
acc[kind] = i18n.ts['_permissions'][kind];
return acc;
}, {}),
},
},
},