Giter Site home page Giter Site logo

beacon-backend's Introduction

beacon-backend's People

Contributors

dependabot[bot] avatar incplusplus avatar

Stargazers

 avatar

Watchers

 avatar  avatar

beacon-backend's Issues

Add basic message handling API to the CIS

Add some basic message sending and retrieving functionality to the CIS server for DMs. This does NOT include Websocket updates. Although, it might be worth looking into whether the client should send new messages using HTTP or via a Websocket message.

Other people's profile pictures don't update

When someone updates their profile picture, it doesn't change for everyone else until they refresh the page. This is because the CIS doesn't notify clients about, well, anything. The CIS doesn't even have any websocket capabilities. While this is a bug behaviorally, it's just an unimplemented feature in reality. This is sorta relevant to IncPlusPlus/beacon-frontend#49.

Implement file storage properly

Currently, file uploads sit on the Heroku dyno. That's a problem because that storage space is ephemeral. Pick an online storage solution and interact with it on the backend. This storage needs to be S3 compatible. We can't just "use" Dropbox or Mega or something.

Current solutions under consideration:

As a follow-up issue, we could keep track of objects so that if the message containing a file is deleted, we could potentially free up storage on our end by deleting the object which no longer has any references to it.

Split the OpenAPI spec files

This is so that they can use shared schemas. For instance, the CIS is going to be capable of handling DMs while the City is capable of hosting Beacons. Both of these will use the same schema for what constitutes a Message. To avoid duplicating these definitions across two OpenAPI specs, it would be advisable to split them and use $refs to reference them.

So that the OpenAPI spec can still be viewable on the deployed services, they will have to be bundled into one spec file at build time before they have the version applied to them.

See this guide and its complete example for more info.

Fix error status codes

I think I've left a bunch of RuntimeExceptions littered in the codebase. These result in erroneous 500 errors when something like a 404 might be appropriate instead. For instance, fetching the messages of a non-existent channel will result in a 500 instead of a 404.

Add permission checks to endpoints that require it

For example, to delete a message, the user attempting to do so must be the owner of that message. Pretty much any of the endpoints in the City that fall under /tower will need to be gone through and we'll have to verify that the user is a member of that Tower.

Get MongoDB connection functioning in production

We need to get a MongoDB connection working in production.

  • I've set up two MongoDB Atlas databases.
  • beacon-east.lw78i.mongodb.net (beacon-backend-qa) is to be used by the beacon-cis-main-staging and beacon-city-main-staging Heroku apps
  • prodcluster0.bdjwu.mongodb.net (beacon-backend-prod) is to be used by the CIS and City Heroku apps which are promoted to production

Have City check its version with the CIS

People self-hosting their Cities might end up with versions that are too old to be compatible with the CIS and/or the frontend client. We could have a very simple CIS endpoint that the City can contact to check what the latest version is. If we wanted to get really fancy with it, we could have the City determine whether there's been a major version change. However, that'll probably be a follow-up feature to this one.

We might also want a way for the client to ask the City if the City believes it is out of date so this information could be displayed to users. Alternatively, we could have the City push the message to the client by itself through a websocket message.

Create profile & instructions for running a self-hosted City

With the introduction of #15, services now communicate between each other and have database connectivity. The next logical step is to create a profile that is configured to use a local database that the user set up. Then, instructions on how to run the service have to be setup. The profile should be added to .gitignore and the file should be named selfhosted-TEMPLATE.yml.

Implement a way to find Tower memberships & better City-to-CIS communications

The endpoint to get tower memberships needs to be implemented. That's a simple way of putting it. To be more specific, I need to find a better way for Cities to be registered and for communications to not break down if somebody shuts down their City temporarily or permanently.

  • The CIS knows what Cities are registered with it. It can return that list of Cities which includes hostnames that the client could iterate over to find if the user is a member of any Towers within it. However, that's a huge chore and a one-time request would be a lot easier.
  • If a one-time request is to be implemented, here are my different ideas of how that could be implemented
    1. Instead of making the client iterate over all the hostnames of the different registered cities, the backend could do it and send back the result to the client.
      • This could cause errors that will be difficult to make clear to the client
    2. Change the City registration system so that the any Cities that are no longer online for 5 minutes are removed from the registry.
      • I'd have to refactor the way that Cities manage their config. However, that's probably not a big deal. The City will just register itself every time on startup and won't retain any config.
      • The CIS could use Spring's task scheduler to periodically (maybe every five minutes) send some kind of request to the City
        • This request could potentially be authenticated by the City with some kind of shared key that the CIS establishes when the City first registers itself on startup.
        • If the City doesn't respond to the CIS request (effectively a reverse heartbeat)
    3. I could stop reinventing the wheel and actually perform service discovery

Regardless of which of these I choose, I'll still need to think of a better way to do this. If we make the City registrations ephemeral, we want some way to permanently persist some kind of static City identifier. That way, if the City has to re-register itself, it won't lose its ID which would cause invites and stuff to fail (due to changing the City ID).

Add query params to the GET /messages endpoint for time range and limit

When fetching the messages in a channel, we don't necessarily need every message since that channel's inception. Instead, we most likely want the most recent N messages or potentially a range of messages. One might even want to obtain messages between two timestamps. This issue will be closed once query parameters that would allow such functionality are implemented in this endpoint.

Fix some of the `POST`, `PUT`, and `DELETE` responses

Some of the POST and PUT endpoints respond with 200 instead of 201. I think the endpoint to delete a tower also responds with a 204 which isn't documented in the spec. This is a really small issue and won't cause issues but it just bugs me.

Make some of the OpenAPI schema properties read-only or write-only

@Sciman101 was looking over the OpenAPI spec and asked me if the client was supposed to set things like the ID of a given entity. I completely forgot that the OpenAPI 3.0 specifications allow me to mark properties as read only. This issue may be closed when I've gone through the various objects I've made in the API and add readOnly: true where applicable.

Also, using writeOnly: true on properties like password is something I should've done instead of making a separate CreateAccountRequest.yml for requests to create a new account.

OH YEAH! Also the array of attachment URLs in the Message schema is read only. That gets populated by the server and never the client.

I keep remembering more things. We'd also wanna mark any timestamps as read-only as well.

Add STOMP topics for when users leave and join a Tower

Right now, a client will need to refresh to get the updated list of Towers they're a member of. This would solve that issue.

There's still one caveat. If the user joins a Tower that's on a City they're not a part of yet, there won't yet be an established websocket connection to that City so there's no way to let the client know about this event. That's a problem for later.

I've realized that with the way the flow between the client, CIS, and City works, we could make the client temporarily listen to the City if it's not already being listened to. That way, we'd receive the event from that City telling us that the user is now a member of a tower we weren't previously aware of.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.