Commit Graph

932 Commits

Author SHA1 Message Date
Luna Mendes 7b75202311 tests: add basic test 2018-11-12 04:10:31 -03:00
Luna Mendes 599989f32e Pipfile: add pytest and pytest-asyncio 2018-11-12 02:50:14 -03:00
Luna Mendes 1b637ef3cc pubsub.lazy_guild: remove print and pprint calls 2018-11-12 02:08:48 -03:00
Luna Mendes fad8484a74 pubsub.lazy_guild: use SYNC instead of DELETE->INSERT->DELETE
This makes our implementation go off-spec (depends on what you'd even
call a spec, considering lazy guilds are not documented and probably
won't be), but well... *it works*

There are also a lot of print-debugs on this commit, will clean them up.

 - pubsub.lazy_guild: filter empty groups out of items list
 - pubsub.lazy_guild: check operator's op on Operation.to_dict
 - pubsub.lazy_guild: add resync() method to deal with re-SYNCs easily
 - pubsub.lazy_guild: fix get_item_index and get_group_item_index
 - pubsub.lazy_guild: drop the ops in complex presence updates in favour
    of using resync()
 - pubsub.lazy_guild: resync on group resorting
 - pubsub.lazy_guild: use resync() on role delete
2018-11-12 02:02:56 -03:00
Luna Mendes ea6e228bb4 pubsub.lazy_guild: use member ids instead of presences on main list 2018-11-11 00:14:59 -03:00
Luna Mendes 864f6a5d9f guild.members: add basic handling of nicks in lazy guilds
- pubsub.lazy_guilds: add a list lock to prevent inconsistencies
 - pubsub.lazy_guilds: add a lot of debug info related to list sorting
2018-11-09 19:02:26 -03:00
Luna Mendes f34c3f6296 pubsub.lazy_guilds: fix role_delete not finding group for role
- pubsub.lazy_guilds: add presence reassignment on role_delete
 - pubsub.lazy_guilds: fix getting role_range due to incorrect operators
2018-11-09 17:18:35 -03:00
Luna Mendes 58c818bb68 guild.members: call pres_dispatch on role updates
- presence: fix 'everyone' list detection
2018-11-09 16:38:19 -03:00
Luna Mendes 7103ac01ca pubsub.lazy_guild: sort groups in decreasing position order 2018-11-09 04:33:29 -03:00
Luna Mendes 04de62778c guild.roles: fix position of new roles
new roles will always have position 1
2018-11-09 04:32:19 -03:00
Luna Mendes ad0aa95f64 pubsub.lazy_guilds: add debug calls for role_pos_update 2018-11-09 04:11:52 -03:00
Luna Mendes 1d7a71a6ad pubsub.lazy_guild: bugfixes and better role_* methods
this fixes role_create and role_delete, adds more debug logging
to understand what is going on, etc.

 - pubsub.lazy_guild: promote role_update -> new_role when updating to
    hoist=True
 - pubsub.lazy_guild: promote role_update -> role_delete when updating
    to hoist=False
 - pubsub.lazy_guild: better handling of unknown group items on
    role_delete
2018-11-09 03:56:00 -03:00
Luna Mendes 5fa5aac2f5 pubsub.lazy_guild: bugfixes, take 2 2018-11-09 03:12:48 -03:00
Luna Mendes 17dfeb0f11 pubsub.lazy_guild: bugfixes 2018-11-09 03:09:55 -03:00
Luna Mendes e0011d7a38 pubsub.lazy_guild: add implementation for role_update 2018-11-09 01:47:49 -03:00
Luna Mendes 950b9b83b2 pubsub.lazy_guild: add implementations for new_role and role_pos_update 2018-11-09 01:19:49 -03:00
Luna Mendes 6c63e014ae blueprints.guild.roles: add basic comms between roles bp and lazy guilds
- pubsub.lazy_guild: add LazyGuildDispatcher.dispatch
 - pubsub.lazy_guild: add GuildMemberList.role_delete
2018-11-09 00:47:22 -03:00
Luna Mendes 6245f08289 Merge branch 'lazy-guilds' into 'master'
Lazy guilds

Closes #12, #9, #8, and #2

See merge request luna/litecord!2
2018-11-08 02:12:45 +00:00
Luna Mendes 748eacf112 pubsub.lazy_guild: fix bugs around p_idx calculation 2018-11-07 23:03:48 -03:00
Luna Mendes 3b532fa8b0 blueprints.users: fix settings being updated for everyone 2018-11-07 22:52:26 -03:00
Luna Mendes 134cc0eec8 pubsub.lazy_guild: add draft impl for complex updates 2018-11-07 22:51:16 -03:00
Luna Mendes 8b093d3d16 pubsub.lazy_guild: better algorithm for presence updates
this gives the separation between "complex" and "simple"
presence updates we can generalize on.
2018-11-07 21:07:31 -03:00
Luna Mendes 7be9d30f5d cmd.migration: add debug log 2018-11-07 19:16:44 -03:00
Luna Mendes a394c02477 schemas: add USER_SETTINGS.status 2018-11-07 19:15:07 -03:00
Luna Mendes e1a946eb87 pubsub.lazy_guild: use filter instead of genexpr 2018-11-07 19:10:27 -03:00
Luna Mendes 773ab8fd18 pubsub.lazy_guild: fix fetching user id from item
- pubsub.lazy_guild: fix get_state on unknown session id
2018-11-07 19:08:31 -03:00
Luna Mendes bd9c4cb26c pubsub.lazy_guild: add implementation for pres_update
- utils: fix index_by_func
2018-11-07 18:52:50 -03:00
Luna Mendes c212cbd392 pubsub.lazy_guild: change some instance vars to properties
- utils: add index_by_func
2018-11-07 17:53:31 -03:00
Luna Mendes 7bcd08ef7a pubsub.lazy_guild: remove LazyGuildDispatcher.unsub
states subscribe via shard_query only.
2018-11-07 17:13:30 -03:00
Luna Mendes 3b2f6062fc pubsub.lazy_guild: subscribe user to the given range 2018-11-07 16:41:22 -03:00
Luna Mendes 55f8919689 pubsub.lazy_guilds: add support for 'everyone'-type GMLs
if the everyone role can read the channel, then the member list
will be equivalent to any other list where the everyone role
can read the channel. with this in mind we can generate a "global"
member list directed only for that usecase.

 - permissions: add role_permissions
2018-11-07 04:11:17 -03:00
Luna Mendes 86923cc6e3 README: add migrate instructions 2018-11-06 20:49:43 -03:00
Luna Mendes db9fd783f5 manage.cmd.migration: add rudimentary implementation
Also add table changes for future message embeds.
2018-11-06 20:46:17 -03:00
Luna Mendes c3210bf5b0 manage: add dummy migration command 2018-11-06 18:43:36 -03:00
Luna Mendes a1a914dc87 add manage.py 2018-11-06 17:42:27 -03:00
Luna Mendes 04d89a2214 pubsub.lazy_guilds: major refactor
This makes the whole process of generating a member list
easier to understand and modify (from my point of view).

The actual event dispatching functionality is not on this
commit.

 - permissions: add optional storage kwarg
2018-11-05 22:04:48 -03:00
Luna Mendes 7c274f0f70 channels: add PUT /api/v6/:chan_id/permissions/:overwrite_id
This finishes the basics on channel overwrites.

SQL for instances:
```sql
DROP TABLE channel_overwrites;
```
Then run `schema.sql`.

 - channels: finish implementations for update_{text,voice}_channel
 - storage: fix _overwrite_convert
 - schema.sql: use unique constraint instead of primary key in
    channel_overwrites
2018-11-05 04:12:16 -03:00
Luna Mendes 8ffa14d934 ratelimits.handler: add check for when rule is none (404s) 2018-11-05 03:15:46 -03:00
Luna Mendes c200ab8707 channels: add untested basic channel update
- channels: fix upserts
 - users: fix upserts
2018-11-05 03:12:09 -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 03e42d9a43 users: use UPSERT when setting chan overrides
- channels: fix UPSERT
2018-11-04 23:46:18 -03:00
Luna Mendes 7ce59398c4 channels: use UPSERT on channel_ack 2018-11-04 23:41:52 -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 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