forked from alemi/upub
chore: ok clippy
This commit is contained in:
parent
c361528b2f
commit
1a7a4f6df6
4 changed files with 10 additions and 12 deletions
|
@ -3,20 +3,20 @@ use sea_orm::{ColumnTrait, Condition, EntityTrait, PaginatorTrait, QueryFilter,
|
||||||
|
|
||||||
use crate::{activitypub::{jsonld::LD, JsonLD, Pagination}, activitystream::{object::collection::{page::CollectionPageMut, CollectionMut, CollectionType}, BaseMut, Node}, model, server::Context, url};
|
use crate::{activitypub::{jsonld::LD, JsonLD, Pagination}, activitystream::{object::collection::{page::CollectionPageMut, CollectionMut, CollectionType}, BaseMut, Node}, model, server::Context, url};
|
||||||
|
|
||||||
pub async fn follow___<const out: bool>(
|
pub async fn follow___<const OUTGOING: bool>(
|
||||||
State(ctx): State<Context>,
|
State(ctx): State<Context>,
|
||||||
Path(id): Path<String>,
|
Path(id): Path<String>,
|
||||||
Query(page): Query<Pagination>,
|
Query(page): Query<Pagination>,
|
||||||
) -> Result<JsonLD<serde_json::Value>, StatusCode> {
|
) -> Result<JsonLD<serde_json::Value>, StatusCode> {
|
||||||
let follow___ = if out { "following" } else { "followers" };
|
let follow___ = if OUTGOING { "following" } else { "followers" };
|
||||||
let limit = page.batch.unwrap_or(20).min(50);
|
let limit = page.batch.unwrap_or(20).min(50);
|
||||||
let offset = page.offset.unwrap_or(0);
|
let offset = page.offset.unwrap_or(0);
|
||||||
if let Some(true) = page.page {
|
if let Some(true) = page.page {
|
||||||
|
|
||||||
use model::relation::Column::{Following, Follower};
|
use model::relation::Column::{Following, Follower};
|
||||||
match model::relation::Entity::find()
|
match model::relation::Entity::find()
|
||||||
.filter(Condition::all().add(if out { Follower } else { Following }.eq(id.clone())))
|
.filter(Condition::all().add(if OUTGOING { Follower } else { Following }.eq(id.clone())))
|
||||||
.select_column(if out { Following } else { Follower })
|
.select_column(if OUTGOING { Following } else { Follower })
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(page.offset.unwrap_or(0))
|
.offset(page.offset.unwrap_or(0))
|
||||||
.all(ctx.db()).await
|
.all(ctx.db()).await
|
||||||
|
|
|
@ -60,6 +60,7 @@ impl MigrationTrait for Migration {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(DeriveIden)]
|
#[derive(DeriveIden)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum Likes {
|
enum Likes {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
@ -69,6 +70,7 @@ enum Likes {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(DeriveIden)]
|
#[derive(DeriveIden)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum Shares {
|
enum Shares {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
|
|
@ -140,6 +140,7 @@ impl MigrationTrait for Migration {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(DeriveIden)]
|
#[derive(DeriveIden)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum Likes {
|
enum Likes {
|
||||||
Table,
|
Table,
|
||||||
Actor,
|
Actor,
|
||||||
|
@ -147,6 +148,7 @@ enum Likes {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(DeriveIden)]
|
#[derive(DeriveIden)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum Shares {
|
enum Shares {
|
||||||
Table,
|
Table,
|
||||||
Actor,
|
Actor,
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
use crate::activitypub::jsonld::LD;
|
use crate::activitystream::key::PublicKey as _;
|
||||||
use crate::activitystream::key::{PublicKey as _, PublicKeyMut as _};
|
|
||||||
use crate::activitystream::object::actor::ActorMut as _;
|
|
||||||
use crate::activitystream::object::document::{DocumentMut as _, DocumentType};
|
|
||||||
|
|
||||||
use crate::activitystream::object::ObjectMut as _;
|
use crate::{activitypub, activitystream::object::actor::{Actor, ActorType}};
|
||||||
use crate::activitystream::{BaseMut as _, Object as _};
|
|
||||||
use crate::{activitypub, activitystream::{object::actor::ActorType, BaseType, Node, ObjectType}};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "users")]
|
#[sea_orm(table_name = "users")]
|
||||||
|
@ -40,7 +35,6 @@ pub struct Model {
|
||||||
// pub streams: Option<String>,
|
// pub streams: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::activitystream::object::{actor::Actor, collection::Collection, document::Image};
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
|
|
Loading…
Reference in a new issue