Git Product home page Git Product logo

collaction_backend's People

Contributors

edreinoso avatar micheldias avatar midepeter avatar mrsoftware avatar nwokoyechigozie avatar qalifah avatar rubenhorn avatar sobowale-olayiwola avatar victoralagwu avatar xazin avatar zen37 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

collaction_backend's Issues

Unsigned JWT for testing

If the template parameter for FirebaseProjectId is empty, allow unsigned JWTs for easier testing.

[Api2] [Doc] Pagination (documentation)

Pagination in the API should be implemented as an extension to JSend.
A successful response may include the field nextPage (null, if it does not exist) and should accept the query parameter page with a default value if not present.

Example request:

GET /some/path?page=<PAGE_ID>

Example response:

{
   "status": "success",
   "data": { ... },
   "nextPage": <PAGE_ID>
}

⚠ Please update the API documentation when implementing pagination.
(This ticket should remain open until all "legacy" features have been switched to pagination)

Refactor API

  • Apply JSend with schema version checking
  • Returned different schema for listing crowdactions
  • Private crowdaction password handling
  • #24

Convenient makefile containing developer commands

Create and document a GNU Make makefile that invokes all frequently used commands as suggested in #90.

  • Update MFA credentials (invoke python script)
  • Build SAM application
  • Deploy developer test stack
  • Run tests
  • etc?

Find friends by phone number

⚠ Blocked until friend or follower feature is defined and planned

  • endpoint maps list of (name, phone_number) to list of (name, userID)
  • Authentication required
  • Prevent scraping using Hashcash (see #58)
  • API documentation is updated
  • GSI for user profile (phone_number -> userID)
  • Privacy: Opt-In/Opt-Out

Participants/participations

Tasks:

  • Return crowdaction list (see /crowdactions) under /profiles/{userID}/participations
  • Return participant list (see field top_participants) under /crowdactions/{crowdactionID}/participations
  • Pagination
  • API documentation is updated (!)

Event for /whoami

Event for /whoami seems to be missing.
Create and test in AWS console.

Badges

⚠ Blocked by #111

  • Claim/award (app API vs CMS API ❓ 👉 TBD ❗) badges for crowdactions
  • See badges in profile
  • Update API documentation

Pagination for crowdactions

From Jira CAN-99:

Currently, there is no pagination needed as the list of actions is small but hopefully, there will be a lot of them so pagination will be mandatory in the end
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.Pagination.html

Outline:
New query parameter page: e.g. api-dev.collaction.org/crowdactions?status=ended&page=eyJwayI6ImFjdCIsInNrIjoic3VzdGFpbmFiaWxpdHkjZm9vZCN2ZWdhbk1vbnRoMjAtMTIifQ==

New response:

{
  data: [...], // The list of crowdactions returned by the backend
  next_page: "eyJwayI6ImFjdCIsInNrIjoic3VzdGFpbmFiaWxpdHkjZm9vZCN2ZWdhbk1vbnRoMjAtMTIifQ==" // Next page key as Base64 or null
}

Obtaining value for next_page to return from models/crowdactions.go#listCrowdactions:

  1. Variable startFrom is of type utils.PrimaryKey (aka map[string]*dynamodb.AttributeValue)
  2. If this variable is null or empty, return null
  3. Marshal this variable as a JSON string (avoid optional whitespace characters. E.g. {"pk":"act","sk":"sustainability#food#veganMonth20-12"})
  4. Convert JSON string to base64
    Obtain parameter startFrom for models/crowdactions.go#listCrowdactions:
    (See above, but just in reverse)

Shorter page IDs:
Instead of converting the primary key to a JSON file, concatenate pk and sk and obtain the base64 string which should reduce the length of the generated page ID. Here is an example using the same primary key:
JSON → eyJwayI6ImFjdCIsInNrIjoic3VzdGFpbmFiaWxpdHkjZm9vZCN2ZWdhbk1vbnRoMjAtMTIifQ==
pk.skYWN0LnN1c3RhaW5hYmlsaXR5I2Zvb2QjdmVnYW5Nb250aDIwLTEy

[Research/Discussion] Use method chaining to avoid duplicate logic and unmaintainable code

From Slack:
Thoughts on using a page out of Java's book with the class StringBuilder (and maybe method chaining) to consistently and maintainably implement request handling on the backend?
Example:

func handler(ctx context.Context, req events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) {
   handlerChain := new(HandlerChain)
            .append(validateRequestMyHandler) // Check parameters
            .append(authentiate) // (optional) Store user info in ctx
            .append(processRequestMyHandlerPart1)
            .append(processRequestMyHandlerPart2) // There could be multiple steps to processing a request
            .append(processRequestMyHandlerPart3)
   return handlerChain.handle(ctx, req)
}

Every handler only invokes the next one if there is no error, otherwise it returns the error response.
This way we can return an error using shared code without adding unrelated logic to the handlers.

Please discuss! 🙂

Periodic regression testing

To ensure that all features are working, we should perform regression testing on the entire backend:

  • Spin up a temporary Cloud Formation stack and tear it down after the test
  • Create code to test cases on the live backend over HTTP
  • ❓ How to deal with timeouts or partial test fails
  • (Optional) Scheduled workflow on GitHub actions

Depends on #56

Check-In crowdactions

Some crowdactions should require/offer periodic check-in by participants to continuously track/confirm their participation.
This requires some changes to the API, backend logic and internal state of the participations.

Changes:

  • Track "streak" of participation
  • Allow check-in to "extend streak"
  • Reset streak if check in was missed (should the maximum streak still be stored?)
  • Update API docs

Cache key in workflow

The key of the cache used to store the workflow build artifact does not contain the commit hash which may lead to the wrong build being used in subsequent jobs.
image

Post-join steps

After a user joins a crowdaction, they may see a "pop-up" with additional steps to take in order to improve retention and increase engagement. (see design)

The content is specific to each crowdaction and is stored (DB field post_join_call_to_action containing JSON string).
The following example shows the required fields and implied schema:

{
   "title": "Where to start?",
   "subtitle": "Need help hetting started? Here is an idea for your first groery list, let's go shopping!"
   "action_items": {
      "is_numbered": true,
      "items": ["Garlic", "Rosemary", "Thyme"]
   },
   "call_to_action_subtitle": "Need more ideas? Feel free to join our WhatsApp group and ask around, we would love to help you!",
   "button_dismiss": "Ready to get started",
   "button_action": {
      "text": "Join us on WhatsApp",
      "link": "https://chat.whatsapp.com/..."
   }
}

Steps:

  • Crowdaction schema in database is updated
  • The schema is validated when creating/editing a crowdaction.
  • Documentation in Confluence is updated
  • API documentation is updated

Consolidate documentation

There should only be one place in which the API is documented.
Delete individual README.md files for functions and update docs/api.yml.

Commenting

⚠ Confirm with design and frontend if the specification for this feature is ok!

Tasks:

  • Comment threads are fetched by crowdaction(id) (one thread per crowdaction)
  • Comments can be deleted* by the author (return placeholder for deleted comment in thread)
  • Comments can be edited (?) (indicate with additional boolean field in response item)
  • Pagination
  • API documentation is updated (!)
  • Spam protection e.g. rate limit (How would we implement this? Investigate!)

*Implement using flag, so comments can be "un-deleted".

[Api2] Consolidate error messages

  • Utility function to generate HTTP response for auth error
  • Utility function to generate HTTP response for internal server error
  • Use utility functions for errors in every handler

[Api2] Refactor crowdactions endpoint

Tasks:

  • /crowdactions/{crowdactionID} only returns if the correct password is provided in the request (only if password not empty)
  • review fields returned by /crowdactions (e.g. commitment options should not be returned)
  • Only /crowdactions?status=featured should return the top_participants

see docs/api2.yaml

⚠ Please notify the frontend team about the changed endpoint in the API when merging.

Remove deprecate endpoints

  • Remove deprecate endpoints (/hello, /whoami)
  • Remove corresponding event JSON files
  • Update API documentation

[Bug] Unresolved resource dependency

Bug:

Error: Failed to create changeset for the stack: dev-some-developer, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Template format error: Unresolved resource dependencies [StaticContentDistribution] in the Resources block of the template

How to reproduce it:
Follow the instructions for deploying a developer stack here.

Issue:
StaticContentDistribution is not defined when deploying without the parameter DomainParameter.

Solution:
Conditionally set value of the environment variable CLOUDFRONT_DISTRIBUTION using:
!If [shouldUseCustomDomainNames, !Ref StaticContentDistribution, ""] (ternary operator).
A condition to ignore empty values for this environment variable parameter already exists, so no further action should be required. (Nonetheless the corresponding feature should be tested after this change)

Migrate to Unix timestamps

Currently, date values are stored as serialized strings.
This has a few disadvantages:

  • Off-by-one errors are not insignificant (error of 24h)
  • Events occur only in one timezone at the "correct" time (Midnight in Frankfurt is not midnight in other parts of the world)
  • (Parsing date strings may fail, if different formats are used)

To mitigate this, we should switch to using unix timestamps instead.
Things this approach would not solve:

  • A deadline that is set for midnight in Europe would still be at a different time of day in other parts of the world
    (However this is also not desired behavior, because it would give more or less time depending on the location of the user. Instead, we should allow for higher precision accurate to at least one hour)

❗ This is merely a suggestion that has pros and cons. Feel free to discuss 🤔💬

Steps

  • Date/time variables are stored as unix timestamps
  • Business logic evaluates and compares unix timestamps
  • API is updated (coordinate with frontend)

[Api2] Refactor contact endpoint

see /contact in docs/api2.yaml

  • Successful response matches API spec
  • Error response matches API spec
  • Request is validated according to API spec (nonce refers to feature #58 and should not be a required field for now, but it should be allowed)
  • Header X-CollActionAPI-Version is optional in request and loaded, but not further processed (maybe leave todo in the code)

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.