mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 01:24:04 +00:00 
			
		
		
		
	Add post with PDF support
This commit is contained in:
		@@ -61,7 +61,7 @@ impl PostAPI {
 | 
			
		||||
        match &p.kind {
 | 
			
		||||
            PostKind::POST_KIND_TEXT => { /* do nothing */ }
 | 
			
		||||
 | 
			
		||||
            PostKind::POST_KIND_IMAGE(file) => {
 | 
			
		||||
            PostKind::POST_KIND_IMAGE(file) | PostKind::POST_KIND_PDF(file) => {
 | 
			
		||||
                post.file_size = Option::from(file.size);
 | 
			
		||||
                post.file_type = file.file_type.clone();
 | 
			
		||||
                post.file_path = Some(file.path.clone());
 | 
			
		||||
@@ -75,7 +75,6 @@ impl PostAPI {
 | 
			
		||||
                post.link_image = link.image.clone();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            PostKind::POST_KIND_PDF => {}
 | 
			
		||||
            PostKind::POST_KIND_MOVIE => {}
 | 
			
		||||
            PostKind::POST_KIND_COUNTDOWN => {}
 | 
			
		||||
            PostKind::POST_KIND_SURVEY => {}
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ pub enum PostKind {
 | 
			
		||||
    POST_KIND_TEXT,
 | 
			
		||||
    POST_KIND_IMAGE(PostFile),
 | 
			
		||||
    POST_KIND_WEBLINK(PostWebLink),
 | 
			
		||||
    POST_KIND_PDF,
 | 
			
		||||
    POST_KIND_PDF(PostFile),
 | 
			
		||||
    POST_KIND_MOVIE,
 | 
			
		||||
    POST_KIND_COUNTDOWN,
 | 
			
		||||
    POST_KIND_SURVEY,
 | 
			
		||||
@@ -68,7 +68,7 @@ impl PostKind {
 | 
			
		||||
            PostKind::POST_KIND_TEXT => "text",
 | 
			
		||||
            PostKind::POST_KIND_IMAGE(_) => "image",
 | 
			
		||||
            PostKind::POST_KIND_WEBLINK(_) => "weblink",
 | 
			
		||||
            PostKind::POST_KIND_PDF => "pdf",
 | 
			
		||||
            PostKind::POST_KIND_PDF(_) => "pdf",
 | 
			
		||||
            PostKind::POST_KIND_MOVIE => "movie",
 | 
			
		||||
            PostKind::POST_KIND_COUNTDOWN => "countdown",
 | 
			
		||||
            PostKind::POST_KIND_SURVEY => "survey",
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
use crate::constants::database_tables_names::POSTS_TABLE;
 | 
			
		||||
use crate::data::error::{ExecError, ResultBoxError};
 | 
			
		||||
use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
 | 
			
		||||
use crate::data::post::PostKind::{POST_KIND_IMAGE, POST_KIND_WEBLINK};
 | 
			
		||||
use crate::data::post::PostKind::{POST_KIND_IMAGE, POST_KIND_PDF, POST_KIND_WEBLINK};
 | 
			
		||||
use crate::data::user::UserID;
 | 
			
		||||
use crate::helpers::{database, friends_helper};
 | 
			
		||||
use crate::utils::date_utils::time;
 | 
			
		||||
@@ -168,6 +168,8 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
 | 
			
		||||
            image: res.get_optional_str("image_page")?,
 | 
			
		||||
        }),
 | 
			
		||||
 | 
			
		||||
        "pdf" => post.kind = POST_KIND_PDF(file?),
 | 
			
		||||
 | 
			
		||||
        _ => {}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user