Commit Graph

919 Commits

Author SHA1 Message Date
shockrah
225a874f5d Ignoring secret hmac files 2021-04-25 12:40:53 -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
e2e68c51ba - Removing old client test code in favor of new structure
+ Moving tests to the new client
- Removing web/ module
! Currently all tests are passing 17/17 but the real trickery comes with doing this
on CI which should will likely take some magic somewhere
Or we'll just extend the freechat docker image to finally have all the required
dependancies and just test on that with diesel and what not
2021-04-21 21:38:25 -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
432e94054f Fixing minor errors that were preventing tests fro mbeing ran oops :p 2021-04-21 17:23:00 -07:00
shockrah
38ff0edd39 ! Massive test suite overhaul see details below !
Problem: the old test suite was extremely inflexible
This meant that making new tests took way too much time.

+ This new rework makes the new client's backend much thinner and less "magical"
With less magic going on we can pass way more data more easily to the actual
http-request engine making the convenience wrapper over top it much more flexible

Translating old tests to the new engine might take a while but for now the old
client codebase is completely deprecated and will no longer be used+updated
2021-04-21 17:22:16 -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
ef73b39f4f + Adding db-lib::common::try_error_passthrough
This is more heavily used in Message::send as a way of discerning "real" server errors
from those that are caused  by user input. The name itself might not be super fitting either

* Moving code for inserting textual messages into its own function
This splits up the logic a bit for Message::send but this segment of logic is also
much simpler than that of file upload

* Flattening Message::send overall
Keeping this function as flat as can be is crucial as it is one of the heavier+most
important funcs in the whole JSON API codebase

Files are now also generated correctly and asynchronously
2021-04-21 16:08:23 -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
591e993329 + Adding cache handler for adding lots of messages from one server call
+ Better error logging in cache

! There is still lots of debug logs which at some point need to be built _out_ from prod builds
Also I need some prod builds

+ Adding more return type annotations for clarity/docs sake

- Removed ancient docs in messages module as they were basically just straight up wrong
2021-04-15 19:57:13 -07:00
shockrah
68e22e1b38 - removing uninportant things
+ messages module was for some reason still using legacy url generation(fixed that)
+ switching types to use bigint since everything is u64/i64 on the backend
2021-04-14 23:00:39 -07:00
shockrah
40351f934e + New cache ipc handlers for adding server caches
Interface for this is fiddly and probably requires real docs to be further developed
without losing my mind doc the whole cache at some point
+ New cache ipc handlers for adding a new open web socket
Web socket comes with some basic listeners, however very litte/nothing
is being done check the health of these connections or to try when possible.

+ Cache now adds actual message objects to its message arrays instead of raw strings (wew)
+ Events module has been added to move the parsing logic/validation away from everything else

+ The basic Event structure has some niftier-than-you-think behavior for data acccess which the cache can leverage for more concise+ correct behavior
2021-04-14 23:00:26 -07:00
shockrah
01c245cbba Ignoring more compiled js and building new events module 2021-04-14 22:48:41 -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
894a5bae34 - Removing more behavior from the cache for complexity reduciton
+ Cache is no longer contained in app structure
This should let us later throw this into an Arc<Mutex<>> for better
async support.
! Also more cache access safety is being done on the front end because the cahe doesn't guarantee much on access
Perhaps some convenience wrappers would make this look nicer(with inline)

!!! Main needs a lot of flattening
It's technically not much of a problem since most of the code behind 1/2 match's
which really just bloat the hell out of indentation making it look bad when its not _that_ bad.
However it still bugs me so I should probably do something about that(also (inline))
2021-04-14 22:44:57 -07:00
shockrah
39ae3ba6be Adding example of websocket url 2021-04-14 22:39:06 -07:00
shockrah
0b0bcd5de6 First pass docs for rtc capabilities 2021-04-14 22:38:43 -07:00
shockrah
42d6a77050 - Removing network control from the cache
From this point forward the cache should basically just be a data container.
Methods on the cache object are there for convenience and should only ever
return very simple data [booleans, integers, () etc.].
The cache should also have very litter/no concept of commands to decouple it
from the renderer process.
! list_channels is still implemented in the cache however it remaains a vestige
and will be moved to the net module

Also the client is getting some new packages for websocket connections and
while they work some additional work has to be put in to figure out where fug to
actually place the websocket so that it can update the cache+DOM in a seomewhat sensible fashion
2021-04-11 17:39:54 -07:00
shockrah
3708d2cd08 Removing websocket changes as they don't architecturally work and thus require too many workarounds
A better architecture must be implemented to have good websocket support
2021-04-10 17:09:25 -07:00
shockrah
102c3b2a10 Electron on Linux hangs when making two successive async calls over the network
Without this calls to /channels/list would break after the first API hit
2021-04-10 17:09:25 -07:00
shockrah
72f3461341 ! Due to user-id's being randomly generated it is now much more likely that id's can't be parsed by javascript properly
Json-bigint should help alleviate this issue by correctly parsing numbers for us

- Removing url method in favor of new url property in server config model

+ Building UserConfigs and ServerConfig from typical JS Obects
This should reduce some up front complexity regarding parameters

! Fix: using new url property instead of protocol + host + port

- Reducing upfront complexity of public channels API
* Also moving to using new updated server.url property
* Channels also handles its part of updating the dom now

bigint parsing in configs now

* More switches to server.url property
2021-04-10 17:09:21 -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
283c201e96 * 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:44:24 -07:00
shockrah
f92ced1241 + Websocket setup is almost proper but it completely hangs after we start listening for connections
Of course this is an issue because we can no longer get data from the user
A full rearchitecting may be in order here however its not impossible to modify the current architecture so far

The main issue here is that the cache is doing too much I think

If the termion(main input) task does its thing, and a socket task,
waits around waiting to build a sub task(socket) then we may be able to
pass messages to the socket task to open up sockets when request
This allows us to have shared state via message passing and a main task
can take care of updating the cache.

The renderer can then request data from the cache when it needs to render stuff
2021-04-09 22:10:08 -07:00
shockrah
a0b8e82000 Adding tungstenite for async websocket support 2021-04-09 21:55:31 -07:00
shockrah
abd2537918 really simple debugger logger, will remove at some point but it has use right now 2021-04-09 21:55:04 -07:00
shockrah
bdd4a63a8d * Fixing url construction for websockets 2021-04-09 21:52:57 -07:00
shockrah
5df5329b6c * Fixed authentication parameter parsing for both users and servers
* Jwt is now given over the query string as many websocket libraries make
it hard to pass header parameters
Parsing these values should also work fine but we'll see in time
2021-04-09 18:59:10 -07:00
shockrah
7eb81f38f2 * Fixing bad /message/send route callback
Issue was that we weren't sending the correct headers/body data(ya I know)

- Removing mouse control from app since its completel irrelevant
!+ Putting app messagses behind a mutex for now since they are written to by
sockets and renderer process in the next few patches
2021-04-08 21:21:56 -07:00
shockrah
6088b0836f + Send message callback now implemented
+ channel switcher works as well, although it relies on /lc being ran prior to
its invocation
2021-04-08 15:45:20 -07:00
shockrah
9ad963f097 + Adding POST handler for message sending /message/send
Working as intended
2021-04-08 15:34:46 -07:00
shockrah
fe448d07d4 Better naming scheme for when we start requesting voice channels after this 2021-04-07 22:17:28 -07:00
shockrah
ceabc73cf7 Fixed hanging json-api issue with dev-run script 2021-04-07 21:06:46 -07:00
shockrah
368c9bc95f + Better logging in main
+
2021-04-07 21:06:08 -07:00
shockrah
d030accddc * Adding id to insertion call in db-lib::channel::add
This is done at the driver level because the member id's are randomly generated
u64's
2021-04-07 20:48:58 -07:00
shockrah
86cd551309 Adding option to build release version of tui 2021-04-07 20:42:30 -07:00
shockrah
31dd85d8f0 simple make file to avoid repeatng args all the time 2021-04-07 20:41:54 -07:00
shockrah
704f372c3e + Adding list_channel handler
More agressive channel caching may be required here but it works as an MVP for now

* Switch to hashmap for container of channel caches instead of vector
This should help with cache accesses as we don't have to iterate anymore
Also it makes data fetches much cleaner/shorthanded

* net::list_channels has its own private structure for collecting channels vector
This is basically required and is in the scope of the func itsefl to not pollute any other namespaces
2021-04-07 20:38:06 -07:00
shockrah
8be5547d9e fixed channel api type 2021-04-07 20:24:31 -07:00
shockrah
10e8b7331f + Login route added to net module
! No wrapper goes around this module to avoid fragmentation
Note that basically every network hit is built around try's so they'll all return
HttpResult<T>'s
2021-04-05 17:41:28 -07:00
shockrah
adea888b21 - Removing fluff from config structure 2021-04-05 17:37:43 -07:00
shockrah
0bee002164 + List channels backbone in place
Technically everything is there but I haven't really tested anything yet
Will 100% need fixing + optimizing

+ Switch server Command also working
! Requires a jwt check to avoid expensive+unnecssary network /login hits
! Probably have to hold onto the input to avoid spam somehow

ChannelCache is nearly ready for manipulation
2021-04-05 17:36:24 -07:00
shockrah
5ab2c961f6 - Adding listhost + listchan command variants 2021-04-05 17:00:59 -07:00
shockrah
939ee8c73f + Ignoring empty lines
+ Only adding / on '/' input activation
2021-04-05 16:54:27 -07:00
shockrah
a8d4ca9028 Removing blocking client from reqwest dep as its not needed 2021-04-05 16:53:19 -07:00
shockrah
0bb7c5f49b adding / to start commands now 2021-04-05 14:24:21 -07:00
shockrah
3c10d342eb - Removing dead_code attr from TEXT_CHANNEL
+ Adding Clone derivation to Channel struct
2021-04-04 17:36:58 -07:00
shockrah
a098121ab8 * Messages now grow from the top to the bottom(new messages ontop)
+ Option to enable/disable message-box borders

* Switching over to using bold! macro where applicable (especially in command.rs)
This change mostly reduces the eyesoreness of the termion code
2021-04-04 14:17:39 -07:00
shockrah
6fff48cfab * Messages now grow from the top to the bottom(new messages ontop)
+ Option to enable/disable message-box borders
* Switching over to using bold! macro where applicable
This change mostly reduces the eyesoreness of the termion code
2021-04-04 14:16:54 -07:00