Commit Graph

1348 Commits

Author SHA1 Message Date
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
Luna Mendes a926ed47ae storage: add Storage.get_guild_settings
- gateway.websocket: use Storage.get_guild_settings
 - schema.sql: chande defaults on message_notifications to 0
2018-10-19 04:45:56 -03:00
Luna Mendes 3a9bc22c60 guilds: set message_notifications = guilds.default_message_notifications 2018-10-19 04:45:14 -03:00
Luna Mendes 6865a5772f blueprints.invites: call create_guild_settings 2018-10-19 04:32:26 -03:00
Luna Mendes 809518f85f blueprints.guilds: add create_guild_settings 2018-10-19 04:32:03 -03:00
Luna Mendes 25b34c6a8a enums: add MessageNotifications
- schemas: add msg_notifications type validator
 - schemas: add GUILD_SETTINGS, GUILD_SETTINGS_CHAN_OVERRIDE
2018-10-19 04:31:20 -03:00
Luna Mendes b1a362418c schema: add guild_settings and guild_settings_channel_overrides 2018-10-19 04:30:52 -03:00
Luna Mendes cabc31360a blueprints.relationships: fix blocking when rel already exists
- storage: fix block fetch
2018-10-15 15:54:40 -03:00
Luna Mendes 151715943b blueprints.relationships: sub/unsub friends on friend request changes 2018-10-15 15:43:00 -03:00
Luna Mendes 1d3520876d gateway: more comments and docstrings 2018-10-13 17:30:02 -03:00
Luna Mendes 6be85ea305 litecord.pubsub: add docstrings for all methods 2018-10-13 16:30:05 -03:00
Luna Mendes 3f54f35dce gateway.websocket: only use pure zlib when payload is big
big here being more than 1024 characters.
2018-10-12 23:41:41 -03:00
Luna Mendes 3d96ccda35 blueprints.users: dispatch USER_UPDATE to guilds and friends
- dispatcher: add EventDispatcher.dispatch_many
2018-10-12 23:32:54 -03:00
Luna Mendes a62bc5af46 enums: add own Flags class
to help with understanding of user.flags and message.activity.type
2018-10-12 23:12:14 -03:00
Luna Mendes 1ab8dc0052 storage: only set mobile and phone when secure=True 2018-10-12 21:36:29 -03:00
Luna Mendes 051cdd8ff2 blueprints.users: finish user patch impl
- blueprints.auth: check availability of username on register
 - enums: add UserFlags
 - schemas: add DATA_REGEX, USER_UPDATE
 - storage: add dummy mobile and phone values on get_user
2018-10-12 21:34:45 -03:00
Luna Mendes 9aec27203b blueprints.auth: dispatch USER_UPDATE when setting verify status 2018-10-12 19:13:57 -03:00
Luna Mendes da4ce66a0c storage: multiple enhancements
storage:
 - don't use SELECT * when get_guild'ing
 - use field::text instead of the str() call madness
 - simplify get_member_data_one
 - fix parent_id being an int on get_channel_data
 - add Storage.get_role
 - better mention resolving on get_message
 - remove Storage.get_all_dms
2018-10-12 19:06:13 -03:00
Luna Mendes d28c0f1bc6 litecord.pubsub: add FriendDispatcher
- gateway.websocket: subscribe to friends on startup
 - presence: dispatch to friends on dispatch_pres
 - storage: add Storage.get_friend_ids
2018-10-12 16:17:29 -03:00
Luna Mendes 46fac95979 gateway.websocket: add presences field to ready payload
- presences: add PresenceManager.friend_presences
 - blueprints.auth: fix resend route
 - pubsub: add DispatcherWithState to decrease amount of
    repeated code between GuildDispatcher and ChannelDispatcher
 - storage: fix relationship id field
2018-10-12 02:10:31 -03:00
Luna Mendes c4db99aa9a blueprints.channels: use ChannelDispatcher
for CHANNEL_PINS_UPDATE and TYPING_START
2018-10-11 23:12:07 -03:00
Luna Mendes 919e5ff903 blueprints.channels: fix close_channel for dms
- dispatcher: add sub() and unsub() alias methods
2018-10-11 23:09:27 -03:00
Luna Mendes 20332805b8 blueprints.channels: support dms on message create
- storage: add Storage.get_dm_peer
 - gateway.websocket: subscribe to dms as well as guilds
2018-10-11 23:01:56 -03:00
Luna Mendes efefb0cc2f blueprints.channels: use ChannelDispatcher for MESSAGE_* events
- storage: add Storage.guild_from_channel
2018-10-11 22:12:51 -03:00
Luna Mendes 37d8114ae2 pubsub: add ChannelDispatcher
- pubsub: call ChannelDispatcher from GuildDispatcher when subbing a
    user
2018-10-11 18:56:40 -03:00
Luna Mendes 5372292f0d blueprints.channels: add route to delete read_state of a channel
- blueprints.checks: change return type from snowflake to (ChannelType,
    snowflake)
2018-10-11 17:53:32 -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 b43b220882 blueprints.users: add profiles and mutual friends 2018-10-10 20:07:38 -03:00
Luna Mendes 76f3a9f868 storage: use premium_since instead of premium 2018-10-10 19:16:35 -03:00
Luna Mendes 28f33b0a95 schema: change premium to premium_since
sql for instances:

```sql
-- remove old nitro column
ALTER TABLE users DROP COLUMN premium;

-- add new nitro column
ALTER TABLE users ADD COLUMN premium_since timestamp without time zone DEFAULT NULL;
```
2018-10-10 19:13:59 -03:00
Luna Mendes dd74689224 blueprints.auth: add POST /api/v6/auth/verify/resend 2018-10-10 18:40:00 -03:00
Luna Mendes ebf16754af gateway.opcodes: add CALL_SYNC
- gateway.websocket: add dummy handler for CALL_SYNC
2018-10-10 18:21:18 -03:00
Luna Mendes 71d1adac53 blueprints.users: dispatch USER_NOTE_UPDATE
- gateway.websocket: show packet when bad op
2018-10-10 18:09:39 -03:00
Luna Mendes e210c20d0f various fixes to dms
- blueprints.checks: fix party fetching
 - blueprints.users: fix try_dm_state
 - blueprints.users: fix create_dm
 - blueprints.users: fix create_group_dm being used for 1-on-1 dm
 - gateway.websocket: add support for pure zlib
 - schemas: fix CREATE_GROUP_DM
 - storage: fix _filter_recipients, get_channel and get_dms
2018-10-10 17:53:31 -03:00
Luna Mendes 737129bd20 blueprints.channels: fix channel deletion
- blueprints.guilds: fix channel creation
 - blueprints.relationships: add POST /api/v6/users/@me/relationships
 - storage: add Storage.search_user, for ^
 - storage: fix bug with last_message_id returning "None" (as a str)
2018-10-10 17:09:39 -03:00
Luna Mendes adc6a58179 blueprints.channels: add channel and guild ack routes
SQL for instances: Rerun `schema.sql` for the new table.

 - gateway.websocket: add get_read_state to read_state's ready
 - gateway.websocket: add get_dms on private_channels' ready
 - storage: fix get_dms()
 - storage: add Storage.get_channel_ids()
 - storage: add Storage.get_read_state()
 - schema.sql: add user_read_state table
2018-10-09 22:52:12 -03:00
Luna Mendes 5edcc62be4 blueprints.guilds: fix GUILD_DELETE event when banning 2018-10-09 20:16:40 -03:00
Luna Mendes b0d1c9765c dispatcher: add some dispatch_* methods for backwards compatibility
- dispatcher: add EventDispatcher.remove()
 - blueprints.guilds: use remove() and unsub()
 - gateway.websocket: fix sub_many() call
2018-10-09 20:13:39 -03:00
Luna Mendes aa76cc2c7d litecord.dispatcher: change dispatch_* methods into pubsub backends
- litecord: add pubsub module
 - schemas: change type to snowflake in MESSAGE_CREATE's nonce
2018-10-09 18:56:34 -03:00
Luna Mendes 5afc15c4f6 storage: fix bug on last_message_id
- storage: better member.roles
 - presence: cast guild_id to str
2018-10-04 04:13:46 -03:00
Luna Mendes 0ebbc4cd37 schema.sql: add UNIQUE to dm_channels
This should fix the `schema.sql` errors on 61e36f244b.

```sql
DROP TABLE dm_channels;
```

Then rerun `schema.sql`.
2018-10-03 22:11:07 -03:00
Luna Mendes 61e36f244b blueprints.users, channels: basic dm operations
SQL for instances:

```sql
ALTER TABLE messages
ADD CONSTRAINT messages_channels_fkey
FOREIGN KEY (channel_id)
REFERENCES channels (id)
ON DELETE CASCADE;

ALTER TABLE channel_pins ADD CONSTRAINT pins_channels_fkey
FOREIGN KEY (channel_id)
REFERENCES channels (id)
ON DELETE CASCADE;

ALTER TABLE channel_pins ADD CONSTRAINT pins_messages_fkey
FOREIGN KEY (message_id)
REFERENCES messages (id)
ON DELETE CASCADE;
```

After that, rerun `schema.sql`.

blueprints.channels:
 - check dms on channel_check
 - add DELETE /api/v6/channels/<int:channel_id>

blueprints.users:
 - add event dispatching for leaving guilds
 - add GET /api/v6/users/@me/channels, for DM fetching
 - add POST /api/v6/users/@me/channels, for DM creation
 - add POST /api/v6/users/<int:user_id>/channels for DM / Group DM
    creation

 - schemas: add CREATE, CREATE_GROUP_DM
 - storage: add last_message_id fetching for channels
 - storage: add support for DMs in get_channel
 - storage: add Storage.get_dm, Storage.get_dms, Storage.get_all_dms
 - schema.sql: add dm_channel_state table
 - schema.sql: add constriants for messages.channel_id and channel_pins
2018-10-03 21:49:35 -03:00
Luna Mendes 88bc4ceca8 blueprints.relationships: fix dispatches 2018-10-02 19:16:00 -03:00