Creates a quote
{
"shards": [
{
"body": "Erm... what the spruce?",
"speaker": "mcdade"
}
]
}
Queries a list of quotes. With no parameters it returns the most recent 10 quotes.
q={query}
- Searches the quotes for a list of space separates keywordslt={qid}
- Filters for all quotes less than a given quote id. Used in pagination.limit={num}
- The maximum number of entries to return (default: 10)submitter={username}
- Filters for quotes submitted by a certain userspeaker={username}
- Filters for quotes said by a certain userinvolved={username}
- Filters for submitter OR speakerhidden={bool}
- Filters for quotes that are hidden and visible to user (if admin, this means all hidden quotes. If normal user, this means their hidden quotes)favorited={bool}
- Filters for favorited quotes (default: false)
[
{
"submitter": {
"cn": "Cole Stowell",
"uid": "cole"
},
"timestamp": "2023-10-24T22:03:08.254364",
"shards": [
{
"body": "Erm... what the spruce?",
"speaker": {
"cn": "Wilson McDade",
"uid": "mcdade"
}
}
],
"id": 26,
"vote": "upvote",
"score": 1,
"hidden": false,
"favorited": true
}
]
Queries for a specific quote by id.
{
"submitter": {
"cn": "Cole Stowell",
"uid": "cole"
},
"timestamp": "2023-10-24T22:03:08.254364",
"shards": [
{
"body": "Erm... what the spruce?",
"speaker": {
"cn": "Wilson McDade",
"uid": "mcdade"
}
}
],
"id": 26,
"vote": "upvote",
"score": 1,
"hidden": false,
"favorited": true
}
Deletes a quote by id. Must be the submitter in order to delete.
Hides a quote by id
Upvotes a quote
vote
- Can be eitherupvote
ordownvote
(Required)
Unvotes/removes the vote for a quote
Favorites a quote
Unfavorites a quote
Reports a quote
{
"reason": "Post makes fun of eboard",
}
Resolves all reports for a given quote with some action.
hide
- Whether to hide a quote or not (Default:false
)
Returns a list of reports
[
{
"quote_id": 9,
"reports": [
{
"reason": "Insults eboard",
"timestamp": "2023-10-27T21:09:01.338863",
"id": 10
}
]
}
]
Gets a list of users
GET /api/hidden
Gets a list of hidden quotes. Admin exclusive.
Takes and returns the same data as /api/quotes
[
{
"cn": "Cole Stowell",
"uid": "cole"
},
{
"cn": "Wilson McDade",
"uid": "mcdade"
}
]
{
"revision": "75885a12aa68a3873bd9f88f54dadbeaedfe9460",
"date": "2023-10-30T18:14:00.000000000-04:00",
"build_date": "2023-10-30T22:14:52.337328855Z",
"url": "https://github.com/costowell/quotefault-backend"
}
CREATE TABLE Quotes (
id INT4 PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
submitter VARCHAR(32) NOT NULL,
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
hidden BOOL NOT NULL DEFAULT FALSE
);
CREATE TABLE Shards (
quote_id INT4 REFERENCES quotes(id) ON DELETE CASCADE NOT NULL,
index SMALLINT NOT NULL,
body TEXT NOT NULL,
speaker VARCHAR(32) NOT NULL,
PRIMARY KEY (quote_id, index)
);
CREATE TABLE Reports (
id INT4 GENERATED ALWAYS AS IDENTITY,
quote_id INT4 REFERENCES quotes(id) ON DELETE CASCADE NOT NULL,
reason TEXT NOT NULL,
submitter_hash BYTEA NOT NULL,
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
resolver VARCHAR(32),
PRIMARY KEY (quote_id, submitter_hash)
);
CREATE TYPE vote AS ENUM ('upvote', 'downvote');
CREATE TABLE Votes (
quote_id INT4 REFERENCES quotes(id) ON DELETE CASCADE NOT NULL,
vote VOTE NOT NULL,
submitter VARCHAR(32) NOT NULL,
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (quote_id, submitter)
);
CREATE TABLE favorites (
quote_id INT4 REFERENCES quotes(id) ON DELETE CASCADE NOT NULL,
username VARCHAR(32) NOT NULL,
PRIMARY KEY (quote_id, username)
);