Commit Graph

94 Commits

Author SHA1 Message Date
shockrah
93ad507e4e * Exposing rtc::notify to avoid single use functions
This  also avoid sthe issue of rustc not inling these functions leaving us with more jump than we need
2021-06-12 23:07:25 -07:00
shockrah
634461c591 + First pass of rtc notifications
* Some tests need to happen in order to ensure correct behavior
2021-06-12 23:06:40 -07:00
shockrah
0e607eac1d -* Removing ugle tuple indexing with some cleaner binds
- Removing warning of unused var
+ Adding 404 response to /badge/update/name when the badge_id isn't real
2021-06-07 23:57:41 -07:00
shockrah
ecb55fa4fe * /badge/update/perms {perms} param is now {badge_perms}
This makes the parameter follow the naming convention of badge_*

* badges.id field now uses BIGINT's as intended

* Typo in sql where 'badges' was incorrectly set to 'perms' -_-
2021-06-07 22:42:26 -07:00
shockrah
fa89088094 + Adding new badges tests
! Test bot is once again a massive disaster but at least it scales well /shrug
Should probably refactor test bot to be moar straight forward or something idk

+ Also adding some spacing eye candy to make sure we can read things easily
2021-06-07 22:33:53 -07:00
shockrah
b7c7b8b5e8 * Moving a cloned channel into rtc:channel_create call 2021-06-07 19:37:16 -07:00
shockrah
0e6168a961 + Adding API handlers for /badge/update/* routes
* Fixing permissions for routes
The /badge/update routes all share the same perms for now
2021-05-30 19:54:20 -07:00
shockrah
e754b18687 + Adding hooks for /badge/update/* routes
! /badge/update/* routes have been split into */name|color|perms
2021-05-30 19:35:14 -07:00
shockrah
2d1f9a37db + First pass of db backend and API handlers for badges module
It should be noted that /badge/update needs some more planning so 1 more commit
is justified for it as some consideration must be taken for how individual badge
permissions are going to be handled
2021-05-29 19:13:13 -07:00
shockrah
4352c840ac + Adding Badges API route hooks
! POST /badge/new
! DELETE /badge/delete
! PUT /badge/update
! GET /badge/list
2021-05-29 19:06:43 -07:00
shockrah
4c0888a263 * /message/recent no longer uses unwraps
This should make it way safer
2021-05-29 14:23:47 -07:00
shockrah
32dbbe11eb * Fixing /channel/create response body
Now it always returns a json structure where before only the rtc branch was
doing this.
2021-05-29 14:22:24 -07:00
shockrah
928c6336d3 * Fixing some of the /message/send API hits by including all required match branches
Some tests are still failing however and I have no idea why
2021-05-27 23:17:47 -07:00
shockrah
0b34c25477 * Fixing broken /channels/create due to updated channel structure
The badges_id field has proved to bubble up some issues with updating deep structures
Basically this just means that feature branches for deep features like this are a good idea

! Issue: RTC feature flag was working fine but without the feature flag `Row`'s had no pickup
This meant correct responses were slipping into previously unreachable sections of code
2021-05-26 12:14:43 -07:00
shockrah
990ad347f7 * Change join route to just /join 2021-05-26 12:08:55 -07:00
shockrah
e5e0875037 * Moving rtc calls to build under rtc feature flag
- Marking additional goal met on roadmap

The current build model succesfully builds rtc enabled/disabled builds
2021-05-17 14:49:01 -07:00
shockrah
24b5f11b13 * Better logging in meta module(more logging tags) 2021-05-12 14:14:30 -07:00
shockrah
fbcf16b735 + Adding /neighbor/remove route api code and db-lib code
This patch has not yet been tested but will be in the coming patches

Sumamary: we're just doing a regular delete on the neighbor's table based off
the url field
2021-05-12 14:07:38 -07:00
shockrah
e94c720332 + More comprehensive testing on /neighbor/update
The cases that actually matter should be covered now so I'm confident with this
endpoint's behavior
! A preliminary db::neighbors::get is done to cover the 404 case
Basically if a bad url is used in the request we should 404 the update as there
won't be anything relevant to update
2021-05-12 13:05:52 -07:00
shockrah
8bff61ab71 * Fixed issue where put requests weren't firing with the optional body parameter
This also "fixes" the /neighbor/update route conveniently enough, which had much
better behavior than expected before.

- Remvoing some fluff from debugging
2021-05-12 13:02:42 -07:00
shockrah
a0d60c0568 - Pointless permissions check /message/send handler
Auth module literally does this for us see: auth::valid_perms
2021-05-11 17:27:04 -07:00
shockrah
a941165ea5 + adding /neighbor/update route to dispatch
! This route needs way more testing as its currently failing the prelim test listed right now

! Some more misc changes in testing/mod.rs that aren't imporant at all to anyone
It's just an extra comment
2021-05-11 17:25:51 -07:00
shockrah
1ca17ec6e0 * /neighbor/add handler now uses body for neighbor structure data
This chage is basically required due to the ridiculuous number of parameters that needed to be passed.
Also more POC for showing how serde_json's result type can be used to safely parse http bodies
2021-05-11 17:23:15 -07:00
shockrah
b810a5abba * Fixing message body unwrap to safer unwrap_or
unwrap had a chance to panic where as the unwrap_or now defaults to an empty
Bytes object which lets the code after it fail with an HTTP 400. This is preferrable
to a 500 error as there really is no error, just bad/unpollable input from the
end user.
2021-05-11 13:52:07 -07:00
shockrah
ee5d9fb248 + Better formatting in hyper compact code
+ Adding ADD_NEIGHBOR permissions flag
2021-05-09 23:16:43 -07:00
shockrah
b3c27b86ce * Fixing some json serialization/parsing weirdness in the meta::BASIC_CONFIG initialization
This is part of a bigger change to stop using environment variables around as state as its mega cheese
2021-05-09 23:15:09 -07:00
shockrah
adc5b261e8 + ADD_NEIGHBOR route now supported in API backend
! Requiring a special event in the RTC server docs for this change
2021-05-09 23:14:02 -07:00
shockrah
cdb956a85c Minor changes lumped together
* claim.rng is now seeded from 16 bytes
+ passing Member to auth::login_get_jwt
* Better error loggin on jwt::insert call

+ Moar meta config-caching fixes
Basically lazy static sucks and we have to start accessing meta::basic_config
though a proxy function which forces the initialization on startup
! We should probably init this prior to listening for connections to avoid connection issues

+ New /neighbors/list endpoint which has already passed required checks
2021-05-08 02:03:58 -07:00
shockrah
1c366611d9 + Server tags are now stored in json format(still in the environment variable mind you
Lazy static initialization still allocates once per run so the above is jank but fine(mostly)
	[] Should probably come up with a cleaner way of passing this data around
	The above is very low on the priority list of things to do

+ Now injecting permisions + id via the claim structure which is passed to the
route dispatcher
! For now this is unused further down the decision tree however I'm going to sprinkle
in its incorporation as it lets us avoid string conversions which is p nice
2021-05-08 01:59:31 -07:00
shockrah
c850d42ce1 + Jwt tables - SEE NOTE
! wat - because have to do maintain permissions on a per request level we have
to do this check for permissions at what is basically every level, this does
mean we have to hit the database for a lot of routes however there is a check
that requests go through in order to avoid hitting the database whenever possible

+ rng field in claims now has real purpose
It's purpose is to act as a validator field in the jwt table. By verifying rng
fields we no  longer have to store whole jwt's
2021-05-08 01:29:44 -07:00
shockrah
a628d56e25 - Removing dotenv from required dependancies
+ Leveraging serde_json to use a config.json
This lets us use the same config for both the json-api and the rtc-server without adding dependancies
2021-05-05 15:50:39 -07:00
shockrah
7c8bc8b4fc - Removing warning
! Increasing wait time on client mock script to avoid firing too early
2021-05-01 19:16:18 -07:00
shockrah
34426038d9 * Fixing busted invite test in api client tester
+ Adding some more invite status checks
+ Adding a verbose invite usage check for sanity reasons

- Removing run-api-tests script as it now goes into the /scripts/ directory

+ Adding the wss-hmac setup from the command line arg
It was literally just 1 if statement that I forgot to write in
2021-04-27 13:27:39 -07:00
shockrah
c9658ad5b4 + Adding command line flag [-H/--hmac] to specify hmac file path
This is really just for testing purposes since the files tend to be in
awkward to reach path

- Removing if args.len == 0 check
Basically cannon-fodder tbh

* Auth now reads hmac path from environment var

! All of the above is added for the wss hmac as well

+ Adding command line flag [-W/--wss-hmac] to specify wss-hmac file path
2021-04-26 01:58:18 -07:00
shockrah
90b584eaa2 * Fixing /invites/join as it was returning the wrong struct data 🤦
Secret value given to user was literally the encrypted secret because I forgot
to rebind it

- removing dev key lmaoooo
These are generated super easily and this key doesn't actually go to anything
so its really not a problem, although it is annoying that its there
2021-04-25 12:40:08 -07:00
shockrah
9ab9cdb176 + db-lib::Channel::get added and Returns a Result<Option<Channel>> for simplicity
This is really only for check if a particular channel exists for /messages/recent's backend

* Flattening db-lib::Message::last_n
SHould make code more readable as it now has a more linear flow

* api::Messages::recent_messages now 404's when a channel that doesn't exist is request
2021-04-21 21:33:30 -07:00
shockrah
c4d7eb9111 * api::channels::list_channels has more relevant docs
Better matching against return types so we're not throwing away errors
	This just entails swapping the if let for a match statement

* db-lib::Message::send has more updated docs on what variants of Response it returns

* api::messages::send_message has better error logging now and more relevant comments
2021-04-21 17:14:33 -07:00
shockrah
52676cdd1f - Removing /messages/from_id as its no longer usable with the new id generation model
+ Adding new flags to sample .env file
+ Wrapper script run-api-tests.sh which does as its called
- Removing build.sh in favor of run-api-tests.sh
Makefile takes care of building, and apitests are ran with special script anyway
2021-04-20 12:09:05 -07:00
shockrah
bb2201c00e ! First pass base implementation for /messages/recent
This api method is made for clients to easily say "give me the n[1,100] latest
messages in some channel
This commit contains code that is largely untested but contains some base code
such that I can correct issues in the next _tested_ commit
2021-04-17 15:55:10 -07:00
shockrah
522890fa00 + rtc::new_message now takes a Pool ref to make the second call for the user name
! Start taking public user params like this in the JWT to reduce on network hits
It's cheap and reliable enough but the idea just now came to me so do that at some point
2021-04-14 22:46:31 -07:00
shockrah
89bd257213 * More explicit query string guard in /channels/list endpoint handler
* rtc::make_url now builds websocket urls more robustly incase we have to percent
encode them
2021-04-10 16:45:13 -07:00
shockrah
368c9bc95f + Better logging in main
+
2021-04-07 21:06:08 -07:00
shockrah
3f1dfbf824 Adding rtc notifications to relevant endpoints
! Still need a feature flag to compile this optionally instead of all the time
- Removed warning in main's auth::login_get_jwt call
2021-04-02 13:56:44 -07:00
shockrah
be54ce6a57 - Removing Claim::new since its used once
+ New notify driver function which does the network magic we need
+ Adding event emitters for the following events
"delete-channel"
"create-channel"
"update-nick"
2021-04-02 13:55:21 -07:00
shockrah
e496fbdd1a Message event now asynchonously emitted from /message/send to rtc server
+ Server claims are now also generated per request so this could get some benefit from caching the jwt
One idea is to cache a jwt for a temporary amount of time
+ event! macro also lets us generate json payloads more easily
! Still requiring this module to built under an optional feature however that should be done easily
2021-04-02 12:11:59 -07:00
shockrah
c6a49a8437 User JWT's now have nbf field in claims set in seconds 2021-04-02 12:06:17 -07:00
shockrah
afdeef0a49 More warning removals and more db-lib result wrapping
This should be everything now
2021-03-30 23:00:50 -07:00
shockrah
c45f8d0482 More db-lib ok/err wrapping
Some misc changes that don't really belong with anything else are bundled here
Those changes aren't actually very important however
2021-03-30 22:46:59 -07:00
shockrah
75dcb7b73e No more jwt db checks
Also wrapping relevant db code with ok/err checks
2021-03-30 22:45:39 -07:00
shockrah
5bbc57313f + Json-API now pushes proper new-message event to rtc server correctly
+ Rtc server takes in new-message correctly but with basically no ux/auth for now
This should be fine as we can layer on security afterwards with no issue
2021-03-25 20:46:10 -07:00