Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows a user to save content to view later. #39

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 120 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ actix-web = { version = '^4.1.0', default-features = false, features = ['macros'
aes = { version = '^0.8.1' }
base64 = '^0.13.0'
blake2 = '^0.10.4'
chrono = "0.4.23"
env_logger = '^0.9.0'
futures = '^0.3.21'
hex = '^0.4.3'
Expand Down
175 changes: 175 additions & 0 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,181 @@ paths:
votes:
$ref: '#/components/schemas/votes'

/users/saved/:
post:
summary: Save content (post or comment) to view later.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- content_type
- content_id
properties:
content_type:
type: string
enum:
- post
- comment
content_id:
type: string
$ref: '#/components/schemas/masked-id'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/success'
'400':
content:
application/json:
schema:
type: 'object'
properties:
BadRequest:
type: string
'401':
$ref: '#/components/responses/unauthenticated'
'409':
description: An error occurred saving the content.
content:
application/json:
schema:
type: object
required:
- error
error:
type: string
enum:
- AlreadySaved
'500':
$ref: '#/components/responses/unexpected'
delete:
summary: Delete some saved content.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- content_type
- content_id
properties:
content_type:
type: string
enum:
- post
- comment
content_id:
type: string
$ref: '#/components/schemas/masked-id'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/success'
'400':
content:
application/json:
schema:
type: 'object'
properties:
BadRequest:
type: string
'401':
$ref: '#/components/responses/unauthenticated'
'500':
$ref: '#/components/responses/unexpected'
get:
summary: View the paginated saved user content.
parameters:
- in: query
name: filter
schema:
type: string
example: post
enum:
- post
- comment
description: Allows you to choose between fetching comments or posts.
- in: query
name: after_date
schema:
type: string
example: "2023-02-24T12:22:37.989Z"
description: Allows you to return content with a saved-date after this.
- in: query
name: after_id
schema:
type: string
$ref: '#/components/schemas/masked-id'
description: Helps in ensuring no content is skipped (as could happen using just the `after_date`).
responses:
'200':
content:
application/json:
schema:
type: object
required:
- after_date
- after_id
properties:
after_date:
type: string
example: "2023-02-24T12:21:54.061Z"
after_id:
type: string
$ref: '#/components/schemas/masked-id'
posts:
type: array
items:
type: object
required:
- id
- sequential_id
- reply_context
- text
- created_at
- votes
properties:
id:
$ref: '#/components/schemas/masked-id'
sequential_id:
$ref: '#/components/schemas/masked-sequential-id'
reply_context:
anyOf:
- type: 'null'
- type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/masked-id'
text:
type: string
created_at:
type: string
votes:
$ref: '#/components/schemas/votes'
comments:
type: string
example: to be implemented
'400':
content:
application/json:
schema:
type: 'object'
properties:
BadRequest:
type: string
'401':
$ref: '#/components/responses/unauthenticated'
'500':
$ref: '#/components/responses/unexpected'
/posts/:
get:
summary: List posts
Expand Down
3 changes: 3 additions & 0 deletions src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ pub const PERMITTED_ORIGINS: &[&str] = &[
pub const TRENDING_EPOCH: i64 = 1640995200; // 2022-01-01T00:00:00Z

pub const TRENDING_DECAY: f64 = 103616.32918473207; // 45000 ln 10

/// How many comments or posts to return at once from a user's saved content.
pub const SAVED_CONTENT_PAGE_SIZE: i64 = 5;
Loading