mirror of
https://github.com/LemmyNet/lemmy
synced 2024-10-30 15:21:20 +00:00
80aef61aed
More fixes - fixed docker builds - fixed mentions regex test - fixed DATABASE_URL stuff - change schema path in diesel.toml Address review comments - add jsonb column back into activity table - remove authors field from cargo.toml - adjust LEMMY_DATABASE_URL env var usage - rename all occurences of LEMMY_DATABASE_URL to DATABASE_URL Decouple utils and db Split code into cargo workspaces Co-authored-by: Felix Ableitner <me@nutomic.com> Reviewed-on: https://yerbamate.dev/LemmyNet/lemmy/pulls/67
41 lines
1.0 KiB
Rust
41 lines
1.0 KiB
Rust
use crate::LemmyError;
|
|
use activitystreams::{ext::Extension, Actor};
|
|
use diesel::PgConnection;
|
|
use lemmy_db::{category::Category, Crud};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct GroupExtension {
|
|
pub category: GroupCategory,
|
|
pub sensitive: bool,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct GroupCategory {
|
|
// Using a string because that's how Peertube does it.
|
|
pub identifier: String,
|
|
pub name: String,
|
|
}
|
|
|
|
impl GroupExtension {
|
|
pub fn new(
|
|
conn: &PgConnection,
|
|
category_id: i32,
|
|
sensitive: bool,
|
|
) -> Result<GroupExtension, LemmyError> {
|
|
let category = Category::read(conn, category_id)?;
|
|
let group_category = GroupCategory {
|
|
identifier: category_id.to_string(),
|
|
name: category.name,
|
|
};
|
|
Ok(GroupExtension {
|
|
category: group_category,
|
|
sensitive,
|
|
})
|
|
}
|
|
}
|
|
|
|
impl<T> Extension<T> for GroupExtension where T: Actor {}
|