Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Feed system, user/organization following [MOD-535] #739

Open
wants to merge 80 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
09784ab
WIP end-of-day push
OmegaJak Oct 13, 2023
0530864
Authorize endpoint, accept endpoints, DB stuff for oauth clients, the…
OmegaJak Oct 16, 2023
4163335
OAuth Client create route
OmegaJak Oct 16, 2023
4d1b0bf
Get user clients
OmegaJak Oct 17, 2023
d4b37de
Client delete
OmegaJak Oct 17, 2023
631e953
Edit oauth client
OmegaJak Oct 18, 2023
107a53b
Include redirects in edit client route
OmegaJak Oct 18, 2023
6c8bbf8
Database stuff for tokens
OmegaJak Oct 18, 2023
083f754
Reorg oauth stuff out of auth/flows and into its own module
OmegaJak Oct 18, 2023
aeb45e0
Impl OAuth get access token endpoint
OmegaJak Oct 18, 2023
6450d04
Accept oauth access tokens as auth and update through AuthQueue
OmegaJak Oct 18, 2023
93cd620
User OAuth authorization management routes
OmegaJak Oct 18, 2023
2e4dbb1
Forgot to actually add the routes lol
OmegaJak Oct 18, 2023
8e6d1ff
Bit o cleanup
OmegaJak Oct 18, 2023
ad04fb9
Merge branch 'master' into OAuth
OmegaJak Oct 19, 2023
229f505
Happy path test for OAuth and minor fixes for things it found
OmegaJak Oct 19, 2023
16e7eb2
Add dummy data oauth client (and detect/handle dummy data version cha…
OmegaJak Oct 19, 2023
1c1636d
More tests
OmegaJak Oct 19, 2023
3221381
Another test
OmegaJak Oct 20, 2023
43a64ad
More tests and reject endpoint
OmegaJak Oct 20, 2023
6e78306
Test oauth client and authorization management routes
OmegaJak Oct 20, 2023
309dbff
Merge branch 'master' into OAuth
OmegaJak Oct 20, 2023
0999d25
cargo sqlx prepare
OmegaJak Oct 20, 2023
68481a1
dead code warning
OmegaJak Oct 20, 2023
075b130
Auto clippy fixes
OmegaJak Oct 20, 2023
4e2bcab
Uri refactoring
OmegaJak Oct 20, 2023
f03f6f5
minor name improvement
OmegaJak Oct 20, 2023
022ea62
Don't compile-time check the test sqlx queries
OmegaJak Oct 20, 2023
6eaa35d
Trying to fix db concurrency problem to get tests to pass
OmegaJak Oct 20, 2023
6bdb9c7
Try fix from test PR
OmegaJak Oct 20, 2023
c29f998
Merge branch 'master' into OAuth
OmegaJak Oct 25, 2023
f9246a1
Fixes for updated sqlx
OmegaJak Oct 25, 2023
f486d99
Prevent restricted scopes from being requested or issued
OmegaJak Oct 26, 2023
723a377
Get OAuth client(s)
OmegaJak Oct 26, 2023
bc625fe
Remove joined oauth client info from authorization returns
OmegaJak Oct 26, 2023
5468b0a
Add default conversion to OAuthError::error so we can use ?
OmegaJak Oct 26, 2023
3178755
Rework routes
OmegaJak Oct 26, 2023
3be6305
Consolidate scopes into SESSION_ACCESS
OmegaJak Oct 26, 2023
f26de30
Cargo sqlx prepare
OmegaJak Oct 26, 2023
18fd30e
Parse to OAuthClientId automatically through serde and actix
OmegaJak Oct 26, 2023
54a1c7c
First steps
OmegaJak Oct 20, 2023
20d08f5
Some progress toward user following before needing to upgrade sqlx
OmegaJak Oct 23, 2023
e3ce8d2
little things before starting on feeds
OmegaJak Oct 23, 2023
20cef00
Starting work towards feeds (mostly dealing with dynamic DB stuff)
OmegaJak Oct 23, 2023
cae4288
insert project create event
OmegaJak Oct 24, 2023
d82c936
More generalized get from events
OmegaJak Oct 24, 2023
c8e88be
Starting basics of getting a user's feed
OmegaJak Oct 24, 2023
03ade2b
As requested, remove use of custom postgres enums and types
OmegaJak Oct 25, 2023
196b353
Remove file that shouldn't have been committed
OmegaJak Oct 25, 2023
97585a9
Organization following
OmegaJak Oct 25, 2023
a5d82d4
Only return authorized projects in the feed
OmegaJak Oct 25, 2023
1a81eea
cargo sqlx prepare
OmegaJak Oct 25, 2023
8f9b6f8
Actually use organization follows to get events too
OmegaJak Oct 25, 2023
23120d8
Add offset/limit parameters and explicitly sort by created descending
OmegaJak Oct 25, 2023
f5f7b83
formatting
OmegaJak Oct 25, 2023
5694ca7
Feed tests
OmegaJak Oct 25, 2023
32bd67e
Fix organization id bug and feed tests
OmegaJak Oct 27, 2023
f6e86b1
More feed + following tests
OmegaJak Oct 27, 2023
5530a87
cargo sqlx prepare
OmegaJak Oct 27, 2023
e6df9be
Undo rename
OmegaJak Oct 27, 2023
84287c6
Cargo clippy
OmegaJak Oct 28, 2023
fc3d31b
Remove validation requiring 1 redirect URI on oauth client creation
OmegaJak Oct 30, 2023
1992925
Use serde(flatten) on OAuthClientCreationResult
OmegaJak Oct 30, 2023
5e568e3
Merge branch 'OAuth' into creator_follows_rebased_2
OmegaJak Oct 30, 2023
5a39c63
Merge branch 'master' into creator_follows_rebased_2
OmegaJak Oct 30, 2023
780aae6
Clippy
OmegaJak Oct 30, 2023
48037b1
Code review improvements
OmegaJak Oct 30, 2023
d6d2b0d
Revert attempts at deduplication
OmegaJak Oct 30, 2023
9a00c2d
Merge branch 'master' of http://www.github.com/modrinth/labrinth into…
thesuzerain Nov 1, 2023
3edae49
adds version create and project update
thesuzerain Nov 2, 2023
474ac88
fixed bugs; delayed notification to publishment
thesuzerain Nov 2, 2023
77617c2
removed project update
thesuzerain Nov 2, 2023
f3b8375
fixed nightly failure
thesuzerain Nov 3, 2023
0943ae4
Revert "fixed nightly failure"
thesuzerain Nov 3, 2023
930cd9a
bumped rust version
thesuzerain Nov 3, 2023
e28b4d0
Merge branch 'master' of http://www.github.com/modrinth/labrinth into…
thesuzerain Nov 15, 2023
2b5b5be
merge conflict fixes; passes tests
thesuzerain Nov 15, 2023
647786e
fmt; clippy; prepare
thesuzerain Nov 15, 2023
315a81a
Merge branch 'master' of http://www.github.com/modrinth/labrinth into…
thesuzerain Nov 18, 2023
5ffa116
merge conflicts, fixes deleted data
thesuzerain Nov 18, 2023
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

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

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

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

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

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

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

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

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

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

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

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

7 changes: 7 additions & 0 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 @@ -109,3 +109,4 @@ derive-new = "0.5.9"

[dev-dependencies]
actix-http = "3.4.0"
assert_matches = "1.5.0"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.68.0 as build
FROM rust:1.70.0 as build
ENV PKG_CONFIG_ALLOW_CROSS=1

WORKDIR /usr/src/labrinth
Expand Down
12 changes: 12 additions & 0 deletions migrations/20231020223602_user_and_organization_follows.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE user_follows(
follower_id bigint NOT NULL REFERENCES users ON DELETE CASCADE,
target_id bigint NOT NULL REFERENCES users (id) ON DELETE CASCADE,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (follower_id, target_id)
);
CREATE TABLE organization_follows(
follower_id bigint NOT NULL REFERENCES users ON DELETE CASCADE,
target_id bigint NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
created timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (follower_id, target_id)
);
20 changes: 20 additions & 0 deletions migrations/20231023212957_feeds.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE events(
id bigint NOT NULL PRIMARY KEY,
target_id bigint NOT NULL,
target_id_type text NOT NULL,
triggerer_id bigint NULL,
triggerer_id_type text NULL,
event_type text NOT NULL,
metadata jsonb NULL,
created timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX events_targets ON events (
target_id,
target_id_type,
event_type
);
Geometrically marked this conversation as resolved.
Show resolved Hide resolved
CREATE INDEX events_triggerers ON events (
Geometrically marked this conversation as resolved.
Show resolved Hide resolved
triggerer_id,
triggerer_id_type,
event_type
);
9 changes: 3 additions & 6 deletions src/auth/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,15 @@ pub async fn is_authorized(

pub async fn filter_authorized_projects(
projects: Vec<QueryProject>,
user_option: &Option<User>,
user_option: Option<&User>,
pool: &web::Data<PgPool>,
) -> Result<Vec<crate::models::projects::Project>, ApiError> {
let mut return_projects = Vec::new();
let mut check_projects = Vec::new();

for project in projects {
if !project.inner.status.is_hidden()
|| user_option
.as_ref()
.map(|x| x.role.is_mod())
.unwrap_or(false)
|| user_option.map(|x| x.role.is_mod()).unwrap_or(false)
{
return_projects.push(project.into());
} else if user_option.is_some() {
Expand Down Expand Up @@ -194,7 +191,7 @@ impl ValidateAuthorized for crate::database::models::OAuthClient {

pub async fn filter_authorized_versions(
versions: Vec<QueryVersion>,
user_option: &Option<User>,
user_option: Option<&User>,
pool: &web::Data<PgPool>,
) -> Result<Vec<crate::models::projects::Version>, ApiError> {
let mut return_versions = Vec::new();
Expand Down
Loading
Loading