Commit Graph

1416 Commits

Author SHA1 Message Date
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
Luna Mendes 45559608f3 litecord.storage: fix _chan_overwrites since table changes 2018-10-02 18:37:53 -03:00
Luna Mendes fcddd46d47 schema.sql: add draft for dm_channels
also add name to group_dm_channels, and a group_dm_members table.

SQL for moving to latest schema:

```sql
DROP TABLE dm_channels;
DROP TABLE group_dm_channels;
DROP TABLE channel_overwrites;
DROP TABLE guild_features;
```

Then rerun `schema.sql`.

 - schema.sql: revamp channel_overwrites table
 - schema.sql: add features table
 - schema.sql: make guild_features use the features table
2018-10-02 17:56:20 -03:00
Luna Mendes d7cc5568bc schema.sql: fix possible bug with some message tables
Drop the unused tables:
```sql
DROP TABLE message_attachments;
DROP TABLE message_reactions;
DROP TABLE channel_pins;
```

Rerun `schema.sql` to recreate them with the proper constraints.
2018-10-02 16:51:01 -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 b091bd5c49 Add hazmat impl for OP 8 Request Guild Members
- storage: add Storage.guild_exists, Storage.query_members
2018-10-01 18:07:29 -03:00
Luna Mendes 51f7ea5ad0 gateway.websocket: use Storage.get_user_settings 2018-09-29 23:54:01 -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 4841565f14 schema.sql: add user_settings table
rerunning the schema.sql file should get you up and running.

 - add POST /api/v6/users/@me/consent for consent changes (that get
    ignored)
2018-09-29 22:17:10 -03:00
Luna Mendes 993a2f3b08 blueprints.channels: add dummy search route 2018-09-28 20:08:07 -03:00
Luna Mendes 02f2ee6943 Add some lazy loading handling
Mostly adding guild_id to some events. It isn't complete support for
them, but its some of the way there.

 - storage: give guild_id on get_message

 - gateway.websocket: decrease logging for some stuff
    - a debug log for the whole packet is still there for development
       reasons, maybe i'll put it on a config option.

 - gateway.websocket: dispatch an offline presence when the user has no
    connections tied to them anymore
2018-09-28 19:34:50 -03:00
Luna Mendes b06c07c097 gateway.websocket: add handler for heartbeats
this should keep connections more stable since we reply and update
WebsocketState.last_seq
2018-09-28 17:50:18 -03:00
Luna Mendes d9506f450d schema.sql: change from varchar to text on some fields
unicode!

sql for instances to upgrade:

alter table users alter column username type text;
alter table guilds alter column name type text;
alter table members alter column nickname type text;
alter table roles alter column name type text;
alter table bans alter column reason type text;
2018-09-28 00:54:24 -03:00
Luna Mendes 37c61466a4 blueprints.channels: fix TYPING_START 2018-09-28 00:08:39 -03:00
Luna Mendes f5db1038eb blueprints.invites: fix typo on get_channel_invites 2018-09-27 23:29:55 -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 f346a991c5 gateway.state_manager: handle member_states being empty 2018-09-26 20:32:43 -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 ea9bb52e4f Merge branch 'patch-1' into 'master'
fix script error that would happen randomly

See merge request luna/litecord!1
2018-09-26 21:49:49 +00:00
Bootsy 8a25c9767e fix script error that would happen randomly 2018-09-26 21:48:51 +00:00
Luna Mendes 34eda81e4f remove some print debug 2018-09-26 18:10:43 -03:00
Luna Mendes d242ef230a gateway.websocket: various fixes to presence
- handle BadRequest instead of passing raise_err=False
 - handle status.activities
 - ready: call update_status BEFORE subscribing and dispatching_ready

presence:
 - better presence object on guild_presences

schema:
 - handle activities, change required to false in game
2018-09-26 18:08:12 -03:00
Luna Mendes 14d3149f50 storage: add presence fetching on get_guild_extra 2018-09-22 22:00:25 -03:00
Luna Mendes 3858e20080 Add user notes
- blueprints.users: fix get_other
 - blueprints.users: add dummy get_user_settings,
     patch_current_settings, get_consent, get_harvest and get_library
 - enums: add ExplicitFilter
 - storage: add Storage.fetch_notes
 - schema.sql: add incomplete user_settings table
2018-09-22 20:18:48 -03:00
Luna Mendes 26931425c4 gateway.websocket: fix resuming woes 2018-09-22 19:01:42 -03:00
Luna Mendes bfa0e61a0c gateway.websocket: give random heartbeat_interval 2018-09-12 21:27:19 -03:00
Luna Mendes 25cd85d704 gateway.websocket: rudimentary resuming 2018-09-12 20:53:29 -03:00
Luna Mendes 213eb328b2 gateway.websocket: add implementation for _handle_3
- gateway.websocket: add dummy implementation for _handle_5
2018-09-12 20:35:50 -03:00
Luna Mendes dd4ae44080 gateway.websocket: rudimentary lazy guilds
implementation details are on the docstrings for _handle_14.

 - presence: merge member dict instead of copying some fields from it
2018-09-10 22:32:58 -03:00
Luna Mendes 952b66a28c blueprints.{channels, guilds}: use *Type as enums instead of classes 2018-09-10 20:29:04 -03:00
Luna Mendes ee8cfedf69 schema: change raise_err default to True 2018-09-10 20:25:03 -03:00