Commit Graph

990 Commits

Author SHA1 Message Date
Luna Mendes da8b049174 channel.messages: add permission checks
this commit only adds permission checking to most parts of the
message endpoints.

 - channel.messages: fix extract_limit's default param
 - channel.messages: check send_messages, mention_everyone, send_tts_messages
 - channel.messages: check manage_messages
 - blueprints.checks: add guild_perm_check, channel_perm_check
 - errors: add error_code property, change some inheritance
 - permissions: fix base_permissions
 - storage: fix get_reactions
 - storage: remove print-debug
 - run: use error_code property when given
2018-11-04 19:55:21 -03:00
Luna Mendes 87dd70b4d9 permissions: add basic permission api
- litecord.auth: insert request.user_id
 - storage: add get_member_role_ids
2018-11-04 17:54:48 -03:00
Luna Mendes 818571d336 gateway: add session_start_limit 2018-11-04 16:43:38 -03:00
Luna Mendes c710ad5aaf gateway.websocket: add _ws.session ratelimit 2018-11-04 16:36:11 -03:00
Luna Mendes 1f5f736a8e ratelimits.main: rollback global_bucket to 50/1 2018-11-04 02:24:13 -03:00
Luna Mendes a96b9c5e7f ratelimits.handler: five better retry_after and global flag
- run: add X-RateLimit-Global and Retry-After headers
2018-11-04 02:23:26 -03:00
Luna Mendes 33f893c0ff all: add ratelimit implementation
haven't tested yet, but it should work in theory.

 - gateway.websocket: add the 3 main ws ratelimits
 - litecord: add ratelimits package
 - ratelimits.main: add implementation
 - run: add app_set_ratelimit_headers
2018-11-04 02:06:40 -03:00
Luna Mendes b17cfd46eb run: add dummy ratelimiting handler 2018-11-03 22:48:36 -03:00
Luna Mendes 69fbd9c117 gateway.state_manager: send OP 7 Reconnect to clients
- gateway.websocket: check StateManager flags on new connections
 - gateway.websocket: cancel all tasks on GatewayWebsocket.wsp.tasks
 - run: call StateManager.gen_close_tasks() and StateManager.close() on
    app shutdown
2018-11-03 21:58:51 -03:00
Luna Mendes afb429ec77 gateway: change from 1200 guilds per shard to 1000
to more closely reproduce discord.
2018-11-03 20:58:01 -03:00
Luna Mendes 0f7ffaf717 storage: add Storage.get_reactions
This finishes basic reaction code (both inserting and putting a reaction).

SQL for instances:
```sql
DROP TABLE message_reactions;
```

Then rerun `schema.sql`

 - channel.reactions: fix partial_emoji
 - schema.sql: add message_reactions.react_ts and unique constraint
    instead of primary key
2018-11-02 22:07:32 -03:00
Luna Mendes db7fbdb954 run: load channel_reactions bp 2018-11-02 20:11:23 -03:00
Luna Mendes 1db27a811f litecord.storage: proper fix for missing guild everyone role 2018-11-02 19:20:39 -03:00
Luna Mendes 378809bdd6 all: misc fixes
- gateway.websocket: fix etf dict decode
 - auth: better token parsing
 - auth: fix new_discrim calc
 - channel.messages: call _dm_pre_dispatch on get_messages
 - channels: fix get_pins
 - guilds: make sure guild owner has guild everyone role
 - invites: replace sub_guild to sub
2018-11-02 19:14:41 -03:00
Luna Mendes 2b1f9489b7 channel: add reactions blueprint
SQL for instances:
```sql
DROP TABLE message_reactions;
```
Then rerun `schema.sql`.
2018-11-02 18:29:07 -03:00
Luna Mendes 2f822408b9 channel.messages: add implementation for before, after and around
for GET /api/v6/channels/:id/messages.
2018-11-02 15:26:31 -03:00
Luna Mendes f2d5913672 blueprints: split channels to channel.messages bp 2018-10-28 17:29:43 -03:00
Luna Mendes 8352a3cab4 guild.mod: add POST /guilds/:id/prune 2018-10-28 00:15:56 -03:00
Luna Mendes 5133aab849 guild.mod: fix get_prune 2018-10-28 00:01:59 -03:00
Luna Mendes 4d4b075de9 auth: move last_session update from gateway to auth
this should help in cases where the client has long-lived sessions (more
than a day)
2018-10-27 23:48:28 -03:00
Luna Mendes 80c29265f3 schema.sql: add users.last_session
- gateway.websocket: update users.last_session

SQL for instances:
```sql
ALTER TABLE users ADD COLUMN last_session timestamp without time zone default (now() at time zone 'utc');
```
2018-10-27 23:40:35 -03:00
Luna Mendes 9aa9b3839b guild.mod: add GET /guilds/:gid/prune
- users: fix get_me_guilds
 - run: fix importing mod blueprint
2018-10-27 23:32:50 -03:00
Luna Mendes 65b47e74bf guild: add mod blueprint
to keep moderation-related routes in a single blueprint
2018-10-27 22:27:05 -03:00
Luna Mendes bbc39a953a roles: add DELETE /guilds/:gid/roles/:rid 2018-10-27 22:20:36 -03:00
Luna Mendes 8678c84355 roles: add GET /api/v6/guilds/:id/roles
- guild: add DELETE /api/v6/guilds/:id/bans/:uid
2018-10-27 22:16:03 -03:00
Luna Mendes ce5b75921a members: add role change impl
- lazy_guild: add to online/offline groups when role isnt hoisted
 - schemas: fix MEMBER_UPDATE.nick
2018-10-27 21:50:15 -03:00
Luna Mendes 72465abdcb channels: make sure we release the connection 2018-10-27 20:44:59 -03:00
Luna Mendes ba794de47a channels: add implementation for change channel position 2018-10-27 20:36:04 -03:00
Luna Mendes 660c8d43d9 blueprints.guild.roles: move main pairs algorithm to gen_pairs 2018-10-27 19:36:00 -03:00
Luna Mendes 0e3db251b8 guild.channels: subscribe users to the newly created channel 2018-10-27 02:17:29 -03:00
Luna Mendes 43b0482581 blueprints.guild: split blueprint into channels, members, roles 2018-10-27 02:04:47 -03:00
Luna Mendes 86705b0645 blueprints.guilds: add 2 role endpoints
Add PATCH /api/v6/guilds/:id/roles for multiple position changes for
roles and PATCH /api/v6/guilds/:id/roles/:id for single guild
role changes

 - permissions: add int maigc method
 - schemas: add ROLE_UPDATE and ROLE_UPDATE_POSITION
2018-10-26 21:05:45 -03:00
Luna Mendes 956498ac65 blueprints.guilds: fix guild_owner_check
- blueprints.guilds: fix create_guild_role
 - blueprints.guilds: fix giving ints in the place of snowflakes in some
    events
2018-10-26 16:35:00 -03:00
Luna Mendes a08eb0d068 blueprints.guilds: calculate new role position
- blueprints.guilds: add basic POST /api/v6/guilds/:id/roles
 - schemas: add ROLE_CREATE
 - litecord: add types
2018-10-26 16:21:27 -03:00
Luna Mendes dca1adc6f8 blueprints.guilds: add create_role function 2018-10-26 15:57:24 -03:00
Luna Mendes f8e44d62bd gateway.websocket: handle missing 'channels' on op 14 2018-10-26 04:30:56 -03:00
Luna Mendes 8888534580 blueprints.guilds: misc fixes to channel creation
Instances should run this SQL to maintain consistency with `schema.sql`
```sql
ALTER TABLE guild_channels DROP CONSTRAINT guild_channels_guild_id_fkey;

ALTER TABLE guild_channels ADD CONSTRAINT guild_id_fkey
FOREIGN KEY (guild_id)
REFERENCES guilds (id)
ON DELETE CASCADE;
```
2018-10-26 04:27:48 -03:00
Luna Mendes d2562d3262 schemas: add role_name and verification_level types
- schemas: also fix GUILD_UPDATE.icon and GUILD_CREATE.icon
2018-10-26 04:15:51 -03:00
Luna Mendes 856839d9e7 presence: don't send PRESENCE_UPDATEs about the same user 2018-10-26 03:50:29 -03:00
Luna Mendes e8ebfe6eeb schemas: fix GW_ACTIVITY schema
- blueprints.guilds: use GUILD_CREATE schema
2018-10-26 03:39:11 -03:00
Luna Mendes aaa11be258 blueprints.guilds: add auto-role and auto-channel creation
also simplify a lot of repeated code on the blueprint.

 - litecord: add permissions module
    for future role code

 - schemas: add channel_type, guild_name, channel_name types
 - schemas: add GUILD_CREATE schema
2018-10-26 02:34:17 -03:00
Luna Mendes 75a8e77a21 blueprints.dms: make sure no double dms happen
by first checking existance, then inserting if
none was found.
2018-10-24 19:25:44 -03:00
Luna Mendes 2605836790 dispatcher: add dispatch_filter
- presence: (basic) handle member lists when presence update.
    Note that the respective GUILD_UPDATE_MEMBER_LIST doesn't happen
    yet. we'll need roles beforehand.
2018-10-24 19:09:05 -03:00
Luna Mendes cd4181c327 litecord.pubsub: add more functionality to GuildMemberList
GuildMemberList, as of this commit, can generate a correct list
and handle (some of) the data given in OP 14. The implementation
is still rudimentary and there's a lot of work to finish.

 - dispatcher: add LazyGuildDispatcher
 - gateway.state_manager: add states_raw to fetch
    a single state without uid
 - gateway.websocket: remove rudimentary implementation
    (moved it to GuildMemberList in litecord.pubsub.lazy_guild)
2018-10-24 16:36:24 -03:00
Luna Mendes 1d33e46fd8 pubsub: add lazy_guild 2018-10-19 19:16:29 -03:00
Luna Mendes 79f91cd774 blueprints.users: fix user guild settings
- blueprints.users: make sure a row exists on guild_settings when
    patching
 - schemas: fix all 'bool' types to 'boolean'
 - schemas: fix GUILD_SETTINGS_CHAN_OVERRIDE
 - storage: add Storage.get_guild_settings_one
 - storage: fix Storage.get_guild_settings
2018-10-19 17:36:54 -03:00
Luna Mendes ef5d4f30e1 blueprints: create dms blueprint
It should be safe for instances to run the `schema.sql` file and update.

 - blueprints.users: s/GUILD_SETTINGS_UPDATE/USER_GUILD_SETTINGS_UPDATE
 - storage: fix get_guild_settings returning a dict instead of a list
 - schema.sql: fix types and syntax
2018-10-19 16:21:33 -03:00
Luna Mendes 692f9ef245 blueprints.channels: call try_dm_state on dm pre dispatch 2018-10-19 13:18:14 -03:00
Luna Mendes 8e3b5d79ab blueprints.users: use UPSERT when adding/patching a note
- blueprints.users: move get_mutual_friends to relationships blueprint
2018-10-19 12:17:00 -03:00
Luna Mendes 2df0d843c1 blueprints.users: add patch_guild_settings 2018-10-19 12:01:58 -03:00