diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0a02bce --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "tabWidth": 4 +} diff --git a/docs/api/rights.md b/docs/api/rights.md index e92e9b2..49aa228 100644 --- a/docs/api/rights.md +++ b/docs/api/rights.md @@ -5,41 +5,41 @@ User rights are instance-wide per-user permission toggle that affects instance-wide permissions of users, such as the ability to edit one's own messages. -Right | Value | Grants when it's 1 --- | -- | -- -`OPERATOR` | 1 << 0 | All rights -`MANAGE_APPLICATIONS` | 1 << 1 | Ability to alter or remove others' applications -`MANAGE_GUILDS` | 1 << 2 | Same as the per-guild `MANAGE_GUILD` permission, but applies to all guilds and DM channels, can join any guild without invite -`MANAGE_MESSAGES` | 1 << 3 | Can delete or edit any message they can read -`MANAGE_RATE_LIMITS` | 1 << 4 | Add, change, define rate limits of other users, can also grant others `BYPASS_RATE_LIMITS` when combined with `BYPASS_RATE_LIMITS` and `MANAGE_USERS` -`MANAGE_ROUTING` | 1 << 5 | Create, alter, enable, disable custom message routing rules in any channel/guild -`MANAGE_TICKETS` | 1 << 6 | Respond to or resolve other users' support tickets -`MANAGE_USERS` | 1 << 7 | Create, alter, remove, ban users; create, modify, remove user groups -`ADD_MEMBERS` | 1 << 8 | Can manually add members into their guilds and group DMs -`BYPASS_RATE_LIMITS` | 1 << 9 | Makes the user exempt from all rate limits -`CREATE_APPLICATIONS` | 1 << 10 | Can create, edit, remove own applications -`CREATE_CHANNELS` | 1 << 11 | Can create guild channels and custom channels -`CREATE_DMS` | 1 << 12 | Can create 1:1 DMs (a user without `SEND_MESSAGES` cannot be added however) -`CREATE_DM_GROUPS` | 1 << 13 | Can create group DMs (a user without `SEND_MESSAGES` cannot be added however) -`CREATE_GUILDS` | 1 << 14 | Can create mass invites in the guilds that they have `CREATE_INSTANT_INVITE` -`CREATE_GUILDS` | 1 << 15 | Can create guilds -`CREATE_ROLES` | 1 << 16 | Can create roles and per-guild or per-channel permission overrides in the guilds that they have permissions -`CREATE_TEMPLATES` | 1 << 17 | Can create templates for guilds, custom channels and channels with custom routing -`CREATE_WEBHOOKS` | 1 << 18 | Can create webhooks in the guilds that they have permissions -`JOIN_GUILDS` | 1 << 19 | Can join guilds by using invites or vanity names -`PIN_MESSAGES` | 1 << 20 | Can modify the pinned messsages in the guilds that they have permission -`SELF_ADD_REACTIONS` | 1 << 21 | Can react to messages, subject to permissions -`SELF_DELETE_MESSAGES` | 1 << 22 | Can delete own messages -`SELF_EDIT_MESSAGES` | 1 << 23 | Can edit own messages -`SELF_EDIT_NAME` | 1 << 24 | Can edit own username, nickname and avatar -`SEND_MESSAGES` | 1 << 25 | Can send messages in the channels that they have permissions -`USE_ACTIVITIES` | 1 << 26 | Can use voice activities, such as watch together or whiteboard -`USE_VIDEO` | 1 << 27 | Can use video and screenshare in guilds/channels that they have permissions -`USE_VOICE` | 1 << 28 | Can use voice in guilds/channels that they have permissions -`INVITE_USERS` | 1 << 29 | Can create user-specific invites in the guilds that they have `INVITE_USERS` -`SELF_DELETE_DISABLE` | 1 << 30 | Can delete/disable own account -`DEBTABLE` | 1 << 31 | Can use pay-to-use features once paid -`CREDITABLE` | 1 << 32 | Can earn money using monetisation features in the guilds that have `MONETIZATION_ENABLED` +| Right | Value | Grants when it's 1 | +| ---------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| `OPERATOR` | 1 << 0 | All rights | +| `MANAGE_APPLICATIONS` | 1 << 1 | Ability to alter or remove others' applications | +| `MANAGE_GUILDS` | 1 << 2 | Same as the per-guild `MANAGE_GUILD` permission, but applies to all guilds and DM channels, can join any guild without invite | +| `MANAGE_MESSAGES` | 1 << 3 | Can delete or edit any message they can read | +| `MANAGE_RATE_LIMITS` | 1 << 4 | Add, change, define rate limits of other users, can also grant others `BYPASS_RATE_LIMITS` when combined with `BYPASS_RATE_LIMITS` and `MANAGE_USERS` | +| `MANAGE_ROUTING` | 1 << 5 | Create, alter, enable, disable custom message routing rules in any channel/guild | +| `MANAGE_TICKETS` | 1 << 6 | Respond to or resolve other users' support tickets | +| `MANAGE_USERS` | 1 << 7 | Create, alter, remove, ban users; create, modify, remove user groups | +| `ADD_MEMBERS` | 1 << 8 | Can manually add members into their guilds and group DMs | +| `BYPASS_RATE_LIMITS` | 1 << 9 | Makes the user exempt from all rate limits | +| `CREATE_APPLICATIONS` | 1 << 10 | Can create, edit, remove own applications | +| `CREATE_CHANNELS` | 1 << 11 | Can create guild channels and custom channels | +| `CREATE_DMS` | 1 << 12 | Can create 1:1 DMs (a user without `SEND_MESSAGES` cannot be added however) | +| `CREATE_DM_GROUPS` | 1 << 13 | Can create group DMs (a user without `SEND_MESSAGES` cannot be added however) | +| `CREATE_GUILDS` | 1 << 14 | Can create mass invites in the guilds that they have `CREATE_INSTANT_INVITE` | +| `CREATE_GUILDS` | 1 << 15 | Can create guilds | +| `CREATE_ROLES` | 1 << 16 | Can create roles and per-guild or per-channel permission overrides in the guilds that they have permissions | +| `CREATE_TEMPLATES` | 1 << 17 | Can create templates for guilds, custom channels and channels with custom routing | +| `CREATE_WEBHOOKS` | 1 << 18 | Can create webhooks in the guilds that they have permissions | +| `JOIN_GUILDS` | 1 << 19 | Can join guilds by using invites or vanity names | +| `PIN_MESSAGES` | 1 << 20 | Can modify the pinned messages in the guilds that they have permission | +| `SELF_ADD_REACTIONS` | 1 << 21 | Can react to messages, subject to permissions | +| `SELF_DELETE_MESSAGES` | 1 << 22 | Can delete own messages | +| `SELF_EDIT_MESSAGES` | 1 << 23 | Can edit own messages | +| `SELF_EDIT_NAME` | 1 << 24 | Can edit own username, nickname and avatar | +| `SEND_MESSAGES` | 1 << 25 | Can send messages in the channels that they have permissions | +| `USE_ACTIVITIES` | 1 << 26 | Can use voice activities, such as watch together or whiteboard | +| `USE_VIDEO` | 1 << 27 | Can use video and screenshare in guilds/channels that they have permissions | +| `USE_VOICE` | 1 << 28 | Can use voice in guilds/channels that they have permissions | +| `INVITE_USERS` | 1 << 29 | Can create user-specific invites in the guilds that they have `INVITE_USERS` | +| `SELF_DELETE_DISABLE` | 1 << 30 | Can delete/disable own account | +| `DEBTABLE` | 1 << 31 | Can use pay-to-use features once paid | +| `CREDITABLE` | 1 << 32 | Can earn money using monetization features in the guilds that have `MONETIZATION_ENABLED` | Those individual right bits are combined to create the overall rights. Those rights may be granted to individual users as well as to user groups. diff --git a/docs/client/plugins.md b/docs/client/plugins.md index 560d9c7..3ef894e 100644 --- a/docs/client/plugins.md +++ b/docs/client/plugins.md @@ -2,24 +2,28 @@ ## Philosophy -- Plugins are executed in their environment to prevent security issues -- Plugins can create their own UI and loaded in a separate view _(similar to vscode extensions)_ -- Plugins can access the component Api and therefore extend the client UI -- Plugins can access the WebSocket Connection/Rest API and intercept/transform events -- Plugins are restricted and can only do actions with the corresponding permission -- Plugins should be accessible through a store that needs to verify the plugins (with dev options to sideload plugins/add other stores) +- Plugins are executed in their environment to prevent security issues. +- Plugins can create their own UI and loaded in a separate view _(similar to vscode extensions)_. +- Plugins can access the component Api and therefore extend the client UI. +- Plugins can access the WebSocket Connection/Rest API and intercept/transform events. +- Plugins are restricted and can only do actions with the corresponding permission. +- Plugins should be accessible through a store that needs to verify the plugins (with dev options to load plugins/add other stores). ## Permissions -- Can't access the user's token (token plugins should rather be directly integrated into the client (e.g. account switcher)) -- All permissions must meet the purpose of the plugin and must justify why they need the certain permission to be approved -- Shouldn't be able to make any request, except if it: - - Requests permission to access the api of the network - - Requests permission to access a specific domain (e.g. plugins backend) - - Requests permission to access all domains -- Shouldn't be able to intercept events, except if it: - - Requests permission to a specific event(s) - - Requests permission to all events -- Needs to request permission to be able to extend the client's UI +- Can't access the user's token (token plugins should rather be directly integrated into the client (e.g. account switcher)). +- All permissions must meet the purpose of the plugin and must justify why they need the certain permission to be approved. +- Shouldn't be able to make any request, except if it: -_more coming soon_ + - Requests permission to access the api of the network. + - Requests permission to access a specific domain (e.g. plugins backend). + - Requests permission to access all domains. + +- Shouldn't be able to intercept events, except if it: + + - Requests permission to a specific event(s). + - Requests permission to all events. + +- Needs to request permission to be able to extend the client's UI. + +**_more coming soon_** diff --git a/docs/client/themes.md b/docs/client/themes.md index 076defb..2f7909c 100644 --- a/docs/client/themes.md +++ b/docs/client/themes.md @@ -2,10 +2,10 @@ ## Philosophy -- Themes should look the same on all platforms -- Themes should be made with an visual theme editor to easily create and edit your own themes -- Themes should be combinable to use multiple themes at once -- Themes should be installed and submitted through a theme store with voting options -- Guilds should be able to specify their own themes for compatible clients +- Themes should look the same on all platforms. +- Themes should be made with an visual theme editor to easily create and edit your own themes. +- Themes should be combinable to use multiple themes at once. +- Themes should be installed and submitted through a theme store with voting options. +- Guilds should be able to specify their own themes for compatible clients. -_more coming soon_ +**_more coming soon_** diff --git a/docs/contributing/index.md b/docs/contributing/index.md index 62c799b..14ec177 100644 --- a/docs/contributing/index.md +++ b/docs/contributing/index.md @@ -4,54 +4,54 @@ By contributing you accept the code of conduct. ## Code of conduct -This is the code of conduct for the Fosscord developer community. It is based on Artemis Lena Code of Conduct by FantasyCookie17. As it is licensed CC0, it may also be used in modified or non-modified form by other communities without permission by the author. Its purpose is to ensure a civilised, tolerant, compassionate, helpful, pluralistic and peaceful style of communication. +This is the code of conduct for the Fosscord developer community. It is based on Artemis Lena Code of Conduct by FantasyCookie17. As it is licensed CC0, it may also be used in modified or non-modified form by other communities without permission by the author. Its purpose is to ensure a civilized, tolerant, compassionate, helpful, pluralistic and peaceful style of communication. Fosscord developer community includes Fosscord Github repositories and Fosscord development guild. Fosscord developers community is administered by the Fosscord maintainers group. If you contribute to the project in any form (for example through code by a pull request) you guarantee that you have the rights to resign all rights to Fosscord under the AGPLV3 license. -### Desirable behaviour +### Desirable behavior -- If possible, providing help with issues other users may have. If it suits the topic of the community, answer it in there, if it does not, try to link to a community where it is more on topic. -- Accepting other opinions, even if you disagree. This does not exclude the possibility to provide arguments for your own opinion. -- Pinging moderators by mentioning their names in chat in the case of rule violations, especially trolling or spamming. While doing so, do not quote or reply to the violator to prevent extra attention by non-moderators. +- If possible, providing help with issues other users may have. If it suits the topic of the community, answer it in there, if it does not, try to link to a community where it is more on topic. +- Accepting other opinions, even if you disagree. This does not exclude the possibility to provide arguments for your own opinion. +- Pinging moderators by mentioning their names in chat in the case of rule violations, especially trolling or spamming. While doing so, do not quote or reply to the violator to prevent extra attention by non-moderators. In order to have your questions resolved more quickly and efficiently, see also: The XY problem, Don't ask to ask, No Hello and How to Ask Smart Questions -### Undesirable behaviour +### Undesirable behavior -- Talking about things that do not suit the topic of the community. Communities exempt from this rule will mention that in their descriptions. -- Attacking people rather than attacking their arguments (a.k.a. ad hominem). -- Bringing extra attention by people who are not moderators to trolls and spammers. -- Self-censorship for reasons of politeness or similar. As long as you keep it civil and free of insults, it is desirable to discuss issues you have with people directly, rather than letting it build up and later creating drama. It is in the interest of the moderators to make the rooms feel comfortable for a large amount of people, this includes changing their own behaviour where necessary and reasonable. If you feel it is better to discuss in a smaller group, ask the person you have an issue with and/or a moderator whether it is fine to invite them to a private chat. -- Making other users feel uncomfortable, for example by nagging them with questions they have stated they do not want to answer. -- Misgendering, deadnaming and assuming gender. Use the singular they/them and inclusive language where possible. -- Not liking the community. If you do, why don't you just leave? You would be causing discomfort to everyone else as well if you did not. +- Talking about things that do not suit the topic of the community. Communities exempt from this rule will mention that in their descriptions. +- Attacking people rather than attacking their arguments (a.k.a. ad hominem). +- Bringing extra attention by people who are not moderators to trolls and spammers. +- Self-censorship for reasons of politeness or similar. As long as you keep it civil and free of insults, it is desirable to discuss issues you have with people directly, rather than letting it build up and later creating drama. It is in the interest of the moderators to make the rooms feel comfortable for a large amount of people, this includes changing their own behavior where necessary and reasonable. If you feel it is better to discuss in a smaller group, ask the person you have an issue with and/or a moderator whether it is fine to invite them to a private chat. +- Making other users feel uncomfortable, for example by nagging them with questions they have stated they do not want to answer. +- Misgendering, deadnaming and assuming gender. Use the singular they/them and inclusive language where possible. +- Not liking the community. If you do, why don't you just leave? You would be causing discomfort to everyone else as well if you did not. -### Prohibited behaviour +### Prohibited behavior -- Spreading hateful, violent or discriminatory ideologies or conspiracy theories, via images and other media (including avatars) or text (including nicknames), as well as discriminating against any group or person. This includes the use of slurs. -- Spamming. This includes adverts, large amounts of repetitive messages, sending invites to users without asking (invite spam), etc. -- Trolling; intentionally derailing conversations or producing discussions on non-issues. -- Doxing: The disclosure of others' private information without their consent. -- Sharing leaked proprietary source code from Discord Inc.: It is forbidden to share leaked proprietary source code from Discord Inc. Violation may lead to ban and legal consequences. -- Posting media that may cause harm or be triggering to other people. For example, people with photosensitive epilepsy may experience seizures from animations with rapidly changing or flashing colours. -- Actively suppressing opinions of other users. -- Being an undesired bot (bots are undesired if not approved by moderation), or adding an undesired bot to a community. -- Ban evasion (creation of additional accounts to join a community after having been banned from that room). -- If you are a moderator or otherwise have permissions above those of normal users: abusing your permissions for personal motives not compatible with this code of conduct. -- Continued harrassment of other users. -- Posting explicit imagery (sexual content, displays of violence, etc.) or unwanted sexual or romantic advances towards other users. -- Posting content that is illegal to publish or illegal to distribute without permission in Germany. The reason is that in certain cases, especially when it comes to copyright, the service provider (who might be me), may be held liable, and I do not wish to get into legal trouble. -- Abusing loopholes in this code of conduct, for example doing something that is not explicitly covered by the prohibited behaviour, yet is in conflict with the general idea of desirable behaviour. +- Spreading hateful, violent or discriminatory ideologies or conspiracy theories, via images and other media (including avatars) or text (including nicknames), as well as discriminating against any group or person. This includes the use of slurs. +- Spamming. This includes adverts, large amounts of repetitive messages, sending invites to users without asking (invite spam), etc. +- Trolling; intentionally derailing conversations or producing discussions on non-issues. +- Doxing: The disclosure of others' private information without their consent. +- Sharing leaked proprietary source code from Discord Inc.: It is forbidden to share leaked proprietary source code from Discord Inc. Violation may lead to ban and legal consequences. +- Posting media that may cause harm or be triggering to other people. For example, people with photosensitive epilepsy may experience seizures from animations with rapidly changing or flashing colours. +- Actively suppressing opinions of other users. +- Being an undesired bot (bots are undesired if not approved by moderation), or adding an undesired bot to a community. +- Ban evasion (creation of additional accounts to join a community after having been banned from that room). +- If you are a moderator or otherwise have permissions above those of normal users: abusing your permissions for personal motives not compatible with this code of conduct. +- Continued harassment of other users. +- Posting explicit imagery (sexual content, displays of violence, etc.) or unwanted sexual or romantic advances towards other users. +- Posting content that is illegal to publish or illegal to distribute without permission in Germany. The reason is that in certain cases, especially when it comes to copyright, the service provider (who might be me), may be held liable, and I do not wish to get into legal trouble. +- Abusing loopholes in this code of conduct, for example doing something that is not explicitly covered by the prohibited behavior, yet is in conflict with the general idea of desirable behavior. ### Consequences of violation -- Undesirable behaviour will lead to warnings, and later on, if repeated too often, kicks or bans. -- Prohibited behaviour will, in most cases, directly lead to a kick or ban. -- Any kind of violation can lead to removal of the offending content. -- Kicks and bans apply to all communities administrated by Fosscord maintainers group. +- Undesirable behavior will lead to warnings, and later on, if repeated too often, kicks or bans. +- Prohibited behavior will, in most cases, directly lead to a kick or ban. +- Any kind of violation can lead to removal of the offending content. +- Kicks and bans apply to all communities administrated by Fosscord maintainers group. If a moderator violates the code of conduct, make sure to point it out to me. This can lead to warnings and demotion of the moderator. diff --git a/docs/contributing/server.md b/docs/contributing/server.md index 3350892..5127167 100644 --- a/docs/contributing/server.md +++ b/docs/contributing/server.md @@ -8,13 +8,11 @@ Accept the [code of conduct](/contributing/) and follow the server [setup guide] The Gateway is a WebSocket server that is responsible for listening and emitting events. -You can find the Roadmap overview [here](https://github.com/fosscord/fosscord-gateway/projects/3). +For documentation, head over to the [Discord docs](https://discord.dev) as our own documentation is not written yet. -For documentation, head over to the [Discord docs](https://discord.dev). (our own documention is not written yet) +If you want to work on a feature, please comment on the corresponding issue or open a issue so so nobody implements something twice. -If you want to work on a feature please comment on the corresponding issue so we can assign it you that nobody implements something twice. - -For the WebSocket, we use [ws](https://www.npmjs.com/package/ws) and we'll write our own packet handler for the individual opcodes and events. +For the WebSocket, we use the [ws](https://www.npmjs.com/package/ws) package and we'll write our own packet handler for the individual opcodes and events. ## API @@ -71,13 +69,13 @@ The config should have reasonable defaults similar to discord. Only in special cases it should require a third party config value. -The config should be changeable over the admin fosscord-dashboard and update in realtime without the need to restart the servers +The config should be changeable over the [admin dashboard](https://github.com/fosscord/fosscord-server/tree/master/dashboard) and update in realtime without the need to restart the servers. The very first time the server starts, it saves to default config in the database. The next start it will load the config from the database. ### Example -You **should not** `get()` the Config in the root of your file and it instead load the config every time you access a value +You **should not** `get()` the Config in the root of your file and it instead load the config every time you access a value. Import `Config` from fosscord-server-util: @@ -90,8 +88,8 @@ Access the Config in your route: ```js router.get("/", (req: Request, res: Response) => { - // call Config.get() to get the whole config object and then just access the property you want - const { allowNewRegistration } = Config.get().register; + // call Config.get() to get the whole config object and then just access the property you want + const { allowNewRegistration } = Config.get().register; }); ``` @@ -99,7 +97,7 @@ router.get("/", (req: Request, res: Response) => { ### Extending -The default Config is located in [server-util `/src/util/Config.ts`](https://github.com/fosscord/fosscord-server-util/blob/master/src/util/Config.ts) and exports a `interface DefaultOptions` and a `const DefaultOptions` object with reasonable default values. +The default Config is located in [server-util `/src/util/Config.ts`](https://github.com/fosscord/fosscord-server/blob/master/util/src/util/Config.ts) and exports a `interface DefaultOptions` and a `const DefaultOptions` object with reasonable default values. To add your own values to the config, add the properties to the `interface` with corresponding types and add default values to `const DefaultOptions`. @@ -137,7 +135,7 @@ router.get("/members", (req, res) => {}); Every request must contain the authorization header except the `/login` and `/register` route. -You can add additional non-auth routes in [`/src/middlewares/Authentication.ts`](https://github.com/fosscord/fosscord-api/blob/master/src/middlewares/Authentication.ts#L5) +You can add additional non-auth routes in [`/src/middlewares/Authentication.ts`](https://github.com/fosscord/fosscord-server/blob/master/api/src/middlewares/Authentication.ts#L5) To access the user id for the current request use `req.user_id` @@ -167,7 +165,7 @@ A Schema is a Object Structure with key-value objects that checks if the supplie _Notice if you use e.g. BigInt even if you can't supply it with JSON, it will automatically convert the supplied JSON number/string to a BigInt._ -_Also if you want to check for an array of, just put the type inside `[]`_ +_Also if you want to check for an array of, just put the type inside `[]`._ #### Optional Parameter @@ -184,7 +182,7 @@ const max = 32; const type = String; { - username: new Length(min, max, type); + username: new Length(min, max, type); } ``` @@ -195,9 +193,9 @@ this will limit the maximum string/number/array length to the `min` and `max` va ```ts import { check, Length } from "/src/util/instanceOf"; const SCHEMA = { - username: new Length(2, 32, String), - age: Number, - $posts: [{ title: String }], + username: new Length(2, 32, String), + age: Number, + $posts: [{ title: String }], }; app.post("/", check(SCHEMA), (req, res) => {}); ``` @@ -210,26 +208,26 @@ The `errors` structure is a key-value Object describing what field contained the ```json { - "code": 50035, - "message": "Invalid Form Body", - "errors": { - "email": { - "_errors": [ - { - "message": "Email is already registered", - "code": "EMAIL_ALREADY_REGISTERED" + "code": 50035, + "message": "Invalid Form Body", + "errors": { + "email": { + "_errors": [ + { + "message": "Email is already registered", + "code": "EMAIL_ALREADY_REGISTERED" + } + ] + }, + "username": { + "_errors": [ + { + "message": "Must be between 2 - 32 in length", + "code": "BASE_TYPE_BAD_LENGTH" + } + ] } - ] - }, - "username": { - "_errors": [ - { - "message": "Must be between 2 - 32 in length", - "code": "BASE_TYPE_BAD_LENGTH" - } - ] } - } } ``` @@ -239,9 +237,9 @@ To manually throw a `FieldError` import `FieldErrors` import { FieldErrors } from /src/iltu / instanceOf; ``` -To make sure your errors are understood in all languages translate it with [i18next](https://www.i18next.com/translation-function/essentials) and `req.t` +To make sure your errors are understood in all languages translate it with [i18next](https://www.i18next.com/translation-function/essentials) and `req.t`. -So after you have checked the field is invalid throw the `FieldErrors` +So after you have checked the field is invalid throw the `FieldErrors`. ```ts throw FieldErrors(( login: { message: req.t("auth:login.INVALID_LOGIN"), code: "INVALID_LOGIN" }}); @@ -255,19 +253,19 @@ The instance hoster should be able to use any database they want for their speci That is why we use [typeorm](https://typeorm.io/) for database entities (models) for every data structure we use, because typeorm supports many different database engines. -We use strings for all ids and bitfields (Tho when working with bitfields we convert it to BigInts and pass it to the utility `BitField` class) +We use strings for all ids and bitfields (Tho when working with bitfields we convert it to BigInts and pass it to the utility `BitField` class). ### General Have a look at the [typeorm documentation](https://typeorm.io/) to get familiar with it or watch this [tutorial](https://youtu.be/Paz0gnODPE0). -TypeORM supports MySQL, MariaDB, Postgres, CockroachDB, SQLite, Microsoft SQL Server, Oracle, SAP Hana, sql.js +TypeORM supports MySQL, MariaDB, Postgres, CockroachDB, SQLite, Microsoft SQL Server, Oracle, SAP Hana, sql.js. ### Getting Started Import the entity you want to select, manipulate, delete or insert from `@fosscord/util` -[List of all entities](https://github.com/fosscord/fosscord-server/blob/typeorm/util/src/entities/index.ts): `Application, Attachment, AuditLog, Ban, BaseClass, Channel, Config, ConnectedAccount, Emoji, Guild, Invite, Member, Message, RateLimit, ReadState, Recipient, Relationship, Role, Sticker, Team, TeamMember, Template, User, VoiceState, Webhook` +[List of all entities](https://github.com/fosscord/fosscord-server/blob/master/util/src/entities/index.ts): `Application, Attachment, AuditLog, Ban, BaseClass, Channel, Config, ConnectedAccount, Emoji, Guild, Invite, Member, Message, RateLimit, ReadState, Recipient, Relationship, Role, Sticker, Team, TeamMember, Template, User, VoiceState, Webhook` ### Example database query @@ -292,24 +290,27 @@ To add your own database entity, create a new file, export the model and import/ ```ts @Entity("users") export class User extends BaseClass { - // id column is automatically added by BaseClass + // id column is automatically added by BaseClass - @Column() - username: string; + @Column() + username: string; - @JoinColumn({ name: "connected_account_ids" }) - @OneToMany( - () => ConnectedAccount, - (account: ConnectedAccount) => account.user - ) - connected_accounts: ConnectedAccount[]; + @JoinColumn({ name: "connected_account_ids" }) + @OneToMany( + () => ConnectedAccount, + (account: ConnectedAccount) => account.user + ) + connected_accounts: ConnectedAccount[]; - static async getPublicUser(user_id: string, opts?: FindOneOptions) { - return await User.findOneOrFail( - { id: user_id }, - { ...opts, select: [...PublicUserProjection, ...(opts?.select || [])] } - ); - } + static async getPublicUser(user_id: string, opts?: FindOneOptions) { + return await User.findOneOrFail( + { id: user_id }, + { + ...opts, + select: [...PublicUserProjection, ...(opts?.select || [])], + } + ); + } } ``` @@ -328,7 +329,7 @@ import { emitEvent } from "../../../util/Event"; ``` You need to specify whom you want to send the event to, to do that either pass `guild_id`, `user_id` or `channel_id`. -Additionally you need to set the [eventname](https://github.com/fosscord/fosscord-server/blob/typeorm/util/src/interfaces/Event.ts#L465) e.g. `GUILD_DELETE`. +Additionally you need to set the [eventname](https://github.com/fosscord/fosscord-server/blob/master/util/src/interfaces/Event.ts#L539) e.g. `GUILD_DELETE`. ```ts { @@ -340,7 +341,7 @@ Additionally you need to set the [eventname](https://github.com/fosscord/fosscor } ``` -For easy intellisense, annotate the parameter with the corresponding [Event interface](https://github.com/fosscord/fosscord-server/blob/typeorm/util/src/interfaces/Event.ts) from `@fosscord/util`: +For easy intellisense, annotate the parameter with the corresponding [Event interface](https://github.com/fosscord/fosscord-server/blob/master/util/src/interfaces/Event.ts) from `@fosscord/util`: ```ts import { GuildDeleteEvent } from "@fosscord/util"; @@ -354,11 +355,11 @@ Putting it all together: ```ts await emitEvent({ - user_id: "3297349345345874", - event: "GUILD_DELETE", - data: { - id: "96784598743975349", - }, + user_id: "3297349345345874", + event: "GUILD_DELETE", + data: { + id: "96784598743975349", + }, } as GuildDeleteEvent); ``` @@ -370,7 +371,7 @@ To get the permission for a guild member import the `getPermission` from `fossco import { getPermission } from "fosscord-server-util"; ``` -The first argument is the user_id the second the guild_id and the third an optional channel_id +The first argument is the user_id the second the guild_id and the third an optional channel_id. ```ts const permissions = await getPermission(user_id: string, guild_id: string, channel_id?: string) diff --git a/docs/contributing/ui.md b/docs/contributing/ui.md index 8476f51..eaf9170 100644 --- a/docs/contributing/ui.md +++ b/docs/contributing/ui.md @@ -1,14 +1,14 @@ # UI Framework -- see: [@fosscord/ui](https://www.npmjs.com/package/@fosscord/ui) +- see: [@fosscord/ui](https://www.npmjs.com/package/@fosscord/ui) ## Requirements You should be familiar with: -- [Git](https://git-scm.com/) -- [NodeJS](https://nodejs.org/) -- [SCSS](https://sass-lang.com/) +- [Git](https://git-scm.com/) +- [NodeJS](https://nodejs.org/) +- [SCSS](https://sass-lang.com/) ## Getting Started diff --git a/docs/index.md b/docs/index.md index a1b24ba..7e9975f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ ### What is Fosscord? -Fosscord is a free open source selfhostable discord compatible chat, voice and video platform +Fosscord is a free open source self-hostable discord compatible chat, voice and video platform. ## Philosophy @@ -42,7 +42,7 @@ features, so that it is not opinionated. - Discord has already built a great and stable protocol _(don't reinvent the wheel)_ - The community can extend and customize their clients and servers by - selfhosting them and developing and installing addons + self-hosting them and developing and installing addons ## Support diff --git a/docs/resources.md b/docs/resources.md index d055c0f..98a0ec0 100644 --- a/docs/resources.md +++ b/docs/resources.md @@ -2,7 +2,7 @@ - [Documentation](https://docs.fosscord.com) - [Roadmap](https://fosscord.notion.site/2c7fe9e73f9842d3bab3a4912dedd091) (Notion to-do board synced with GitHub issues) -- [Status](https://status.fosscord.com/) (Status page of the offical foscord instance) +- [Status](https://status.fosscord.com/) (Status page of the official fosscord instance) - [GitHub](https://github.com/fosscord/) (GitHub organization) - [OpenCollective](https://opencollective.com/fosscord) (Financially support the project to cover server costs and other expenses) - [Discord server](https://discord.gg/ZrnGQP6p3d) (for support & organization (If we are finished we'll host our own support server)) @@ -20,8 +20,8 @@ Contains: - [api](https://github.com/fosscord/fosscord-server/tree/master/api) a HTTP REST server - [gateway](https://github.com/fosscord/fosscord-server/tree/master/gateway) a WebSocket Gateway server -- [rtc](https://github.com/fosscord/fosscord-server/tree/master/rtc) a _C++_ webrtc server for voice and video sharing. -- [webrtc-server](https://github.com/fosscord/fosscord-server/tree/master/webrtc-server) a _javascript_ webrtc server for voice and video communication +- [rtc](https://github.com/fosscord/fosscord-server/tree/master/rtc) a _C++_ webRTC server for voice and video sharing. +- [webRTC-server](https://github.com/fosscord/fosscord-server/tree/master/webrtc-server) a _javascript_ webRTC server for voice and video communication - [dashboard](https://github.com/fosscord/fosscord-server/tree/master/dashboard) An admin dashboard for the server (analytics, settings, administration, trust & safety) - [util](https://github.com/fosscord/fosscord-server/tree/master/util) contains all shared logic like Database Models, Utility functions... - [cdn](https://github.com/fosscord/fosscord-server/tree/master/cdn) is the content-delivery-content (CDN) that stores user uploaded images. diff --git a/docs/setup/bots.md b/docs/setup/bots.md index 8563d82..e775166 100644 --- a/docs/setup/bots.md +++ b/docs/setup/bots.md @@ -36,12 +36,12 @@ Inside the client option you can specify the api endpoint: const { Client } = require("discord.js"); const client = new Client({ - http: { - version: 9, - api: "https://api.fosscord.com", - cdn: "https://cdn.fosscord.com", - invite: "https://fosscord.com/invite", - }, + http: { + version: 9, + api: "https://api.fosscord.com", + cdn: "https://cdn.fosscord.com", + invite: "https://fosscord.com/invite", + }, }); client.login("your token here");