Commit Graph

102 Commits

Author SHA1 Message Date
Luna Mendes a1a914dc87 add manage.py 2018-11-06 17:42:27 -03:00
Luna Mendes 22fe0f07c6 channel: create channel.pins blueprint
- schemas: add CHAN_UPDATE and CHAN_OVERWRITE
2018-11-05 00:15:59 -03:00
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 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 db7fbdb954 run: load channel_reactions bp 2018-11-02 20:11:23 -03:00
Luna Mendes f2d5913672 blueprints: split channels to channel.messages bp 2018-10-28 17:29:43 -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 43b0482581 blueprints.guild: split blueprint into channels, members, roles 2018-10-27 02:04:47 -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 b7f0bd1bb4 run: pass app instance to EventDispatcher
this should help with future DM channel pub/sub, as we'll
have to query the `dm_channel_state` table.
2018-10-11 16:52:15 -03:00
Luna Mendes c7923da124 relationship support!
friendships and blocks are possible, however presence code isn't ready
to handle presences of people who are friends.

SQL for instances, this is going to fix bad timestamps on the messages:

```sql
ALTER TABLE ONLY members ALTER COLUMN joined_at SET DEFAULT (now() at time zone 'utc');
 ALTER TABLE ONLY messages ALTER COLUMN created_at SET DEFAULT (now() at time zone 'utc');
ALTER TABLE ONLY invites ALTER COLUMN created_at SET DEFAULT (now() at time zone 'utc');
```

After that, rerun the schema.sql file to have the new relationships
table.

 - blueprints: add relationships blueprint
 - enums: add RelationshipType
 - storage: add get_relationships
 - storage: fix bug on lazy guild changes and messages
 - schemas: return validator.document instead of reqjson
 - gateway.websocket: use Storage.get_relationships
2018-10-02 03:43:57 -03:00
Luna Mendes bff5700d06 blueprints.users: add user setting patch impl
- schemas: add explicit type
 - schemas: add USER_SETTINGS
 - run: make Access-Control-Allow-Methods the same as Allow header when
    possible
2018-09-29 23:43:02 -03:00
Luna Mendes 624eb6eb0e blueprints.users: use Storage.get_user_settings
paving the way for user settings support.

 - storage: add Storage.get_user_settings
 - storage: add methods to fetch with json/jsonb codecs enabled
2018-09-29 23:10:42 -03:00
Luna Mendes e7d97ecdef run: have a fallback when Origin header is missing 2018-09-27 23:25:23 -03:00
Luna Mendes 92f6e3cf75 add invite usage
users can now join guilds!

invites:
 - add GET /api/v6/invites/<invite_code>
 - add DELETE /api/v6/invites/<invite_code>
 - add GET /api/v6/guilds/<guild_id>/invites
 - add GET /api/v6/channels/<channel_id>/invites
 - add POST /api/v6/invite/<invite_code>

storage:
 - add verification_level to invites
 - add empty invite.guild.features

gateway.state_manager:
 - add StateManager.user_states
 - give a dummy offline state on guild_states
    - this makes it possible for people to see offline members even when
       those members never logged in (since the would have no state being
       reffered to them)

 - gateway.websocket: use get_member_ids on lazy guild handler
 - auth: add GET /api/v6/auth/consent-required
 - dispatcher: add dispatch_user_guild and dispatch_user
 - run: use Origin header on Access-Control-Allow-Origin
2018-09-27 23:10:30 -03:00
Luna Mendes dc62de37b2 basic invites
- add invites blueprint
 - add POST /api/v6/channels/<channel_id>/invites
 - add GET /api/v6/invites/<invite_code>
 - schema: add INVITE
 - storage: add get_member_ids, get_invite, get_invite_extra,
 get_invite_metadata
2018-09-26 20:29:22 -03:00
Luna Mendes 14d3149f50 storage: add presence fetching on get_guild_extra 2018-09-22 22:00:25 -03:00
Luna Mendes cd5dbc4886 Rough presence management
Lots of changes to get it working.

One day changes will be able to be small enough to be split across
commits.

 - enums: use enum.Enum, make EasyEnum subclass
 - enums: add ActivityType, ActivityFlags, StatusType
 - gateway.state: use 128 random bits instead of 256
 - gateway.state: add MAX_STORE_SIZE in PayloadStore and check it when
    adding a new payload
 - gateway.websocket: add GatewayWebsocket.update_status
 - presence: add PresenceManager.dispatch_guild_pres and
    PresenceManager.dispatch_pres
 - schema: add snowflake, activity_type, status_external types
 - schema: add GW_ACTIVITY, GW_STATUS_UPDATE
 - storage: fix _channels_extra and fixes for ChannelType as enum instead of
    class
2018-09-10 01:09:09 -03:00
Luna Mendes d39783e666 Add barebones implementation for GUILD_SYNC
- state_manager: add StateManager.guild_states
 - add PresenceManager in the presence module
 - fix get_user_guilds not returning ints
 - gateway: add dummy handler for op 4
 - gateway: add hazmat implementation for op 14
 - run: keep websockets logger on INFO
 - run: add more headers on app_after_request
2018-09-01 23:53:36 -03:00
slice 13f6842232
remove unnecessary ** in dict 2018-09-01 19:02:42 -07:00
Luna Mendes 85d4f9e593 run: Add some headers for Access-Control-Allow-Headers 2018-08-21 05:13:38 -03:00
slice db7ea18f09
add voice and science bps 2018-07-21 11:52:21 -07:00
slice 77a260706d
remove quart-cors 2018-07-21 09:37:34 -07:00
Luna Mendes 93933fd8f5 add empty webhooks blueprint 2018-07-06 16:07:42 -03:00
Luna Mendes 6d8af8aef3 Add Quart-CORS 2018-07-06 03:17:38 -03:00
Luna Mendes 0ca45c781e blueprints.channels: add implementations for some routes
more specifically edit/delete message, and all 3 pin-related routes.

 - snowflake: add snowflake_datetime
2018-07-04 17:40:27 -03:00
Luna Mendes 59127ad197 blueprints.channels: add message sending
It is clunky when sending messages as Atomic, nor we have proper channel
management, but it works.

 - dispatcher: add sub_many
 - errors: add failsafe on LitecordError.message
 - errors: add ChannelNotFound
 - gateway.websocket: add dispatcher to WebsocketObjects
 - schemas: add regexes for mentions
 - storage: add get_channel, get_message
2018-07-03 01:02:26 -03:00
Luna Mendes 4ea3d353b3 litecord.blueprints: add channels blueprint 2018-07-02 05:06:57 -03:00
Luna Mendes 3258dc94d5 gateway.websocket: implement ZLIB streaming
With this comment we have a proper READY event that can be
successfully parsed by discord.py! hooray for progress!

 - gateway.websocket: add dummy handler for op 1
 - gateway.websocket: change op 0 to op 2
 - storage: fix 'None' strings on channel IDs
 - run: use logbook.compat.redirect_logging()
2018-06-23 20:16:10 -03:00
Luna Mendes 21da0e0d3a blueprints.guild: add implementations for more routes
- Pipfile: add Cerberus for data validation
 - blueprints.guilds: add guild_owner_check
 - blueprints.guilds: simplify GUILD_MEMBER_UPDATE dispatch
 - litecord: add schemas.py
 - run: get json of errors
2018-06-23 17:19:22 -03:00
Luna Mendes de98d0f609 blueprints.guild: use EventDispatcher
- dispatcher: add sub_guild, unsub_guild, remove_guild, dispatch_guild
 - gateway.state_manager: fix fetch_states
 - gateway.websocket: add current_shard, shard_count to atributes
 - schema: add ON DELETE CASCADE to channel tables
2018-06-21 17:59:08 -03:00
Luna Mendes 183013f8f9 blueprints: add guilds blueprint
- gateway.websocket: merge get_guild and get_guild_extra
 - gateway.websocket: only apply too many shards close when
     guilds > 2500
 - storage: detach state usage
 - storage: fix large calc on get_guild_extra
2018-06-21 03:16:13 -03:00
Luna Mendes f5ea44c8d7 blueprints: add users.py blueprint
- errors: change AuthError to Unauthorized and Forbidden
 - auth: fix bug on token_check
 - storage: add Storage.get_user_guilds
2018-06-20 23:29:30 -03:00
Luna Mendes 3eb6d5e60f litecord: add Storage
Storage serves as a way to reduce code repeatbility. So that we
don't need to keep repeating the same SQL statements over and over,
and to detach some SQL calls into their own code (like guild fetching)

 - gateway.websocket: add WebsocketObjects to hold db, state_manager,
    storage and loop

 - gateway.websocket: add _make_guild_list
 - schema: add members.deafened, members.muted
2018-06-20 16:53:22 -03:00
slice f7d530c787
add a HTTP 500 handler 2018-06-19 18:17:00 -07:00
slice c88148271d
make make_app set app.debug as specified in config 2018-06-19 18:13:13 -07:00
slice efbcbafce4
remove jsonified exception handler 2018-06-19 18:13:03 -07:00
slice ab4857086a
migrate to logbook for logging 2018-06-19 18:04:17 -07:00
slice ff05e278f6
rename state_man -> state_manager 2018-06-19 17:55:23 -07:00
Luna Mendes 6f0528eaec gateway.websocket: detach app object from GatewayWebsocket
It doesn't work since quart's objects only work with stuff
that is already from quart, e.g the current_app stuff
requires you to be inside a special hidden context
that only quart functions get.

Gateway code is detached from quart since quart's websocket
stuff can't handle custom error codes.

 - auth: optional db detach
 - gateway.errors: add InvalidShard, ShardingRequired
 - gateway.gateway: pass asyncpg connection and StateManager
 - gateway.state: add repr, etc
 - gateway.state_man: add remove(), fetch_states()
2018-06-19 21:05:26 -03:00
Luna Mendes 77c5a101c6 gateway.websocket: add basics of identify
- auth: add raw_token_check
 - gateway.gateway: pass the app object to GatewayWebsocket
 - gateway.state: add gen_session_id()
 - gateway: add state_man
2018-06-19 19:09:12 -03:00
Luna Mendes 39d85d1a1a add basis of websockets 2018-06-17 17:07:52 -03:00
Luna Mendes 7e7a6a1aeb blueprints.gateway: add implementations for gateway urls
- config: add DEBUG, IS_SSL, WEBSERVER_URL
    - remove HOST, PORT
 - litecord: add auth module
2018-06-17 14:24:24 -03:00
Luna Mendes f7f387dcf0 litecord.blueprints: add auth blueprint
- Pipfile: add bcrypt and itsdangerous
 - litecord: add errors module
 - litecord: add snowflake module
 - run: add error handlers

 - schema: add UNIQUE constraint to users.email
   - remove users.password_salt
2018-06-17 04:09:29 -03:00
slice 6b066bba05
add base /gateway bp 2018-06-16 17:00:11 -07:00
slice 6350ff688c
clean 2018-06-16 17:00:08 -07:00
Luna Mendes c11851c4b0 add schema.sql
- add basic config example stuff
2018-06-16 19:25:07 -03:00
Luna Mendes 8961838148 add quart basic 2018-06-16 02:33:16 -03:00