mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Add YouTube posts support
This commit is contained in:
		@@ -109,7 +109,10 @@ impl PostAPI {
 | 
				
			|||||||
            PostKind::POST_KIND_SURVEY =>
 | 
					            PostKind::POST_KIND_SURVEY =>
 | 
				
			||||||
                post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, user.clone())?),
 | 
					                post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, user.clone())?),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            PostKind::POST_KIND_YOUTUBE => {}
 | 
					            PostKind::POST_KIND_YOUTUBE(id) => {
 | 
				
			||||||
 | 
					                post.file_path = Some(id.clone());
 | 
				
			||||||
 | 
					                post.file_type = Some("youtube".to_string());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Ok(post)
 | 
					        Ok(post)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,7 +61,7 @@ pub enum PostKind {
 | 
				
			|||||||
    POST_KIND_COUNTDOWN(u64),
 | 
					    POST_KIND_COUNTDOWN(u64),
 | 
				
			||||||
    // End time
 | 
					    // End time
 | 
				
			||||||
    POST_KIND_SURVEY,
 | 
					    POST_KIND_SURVEY,
 | 
				
			||||||
    POST_KIND_YOUTUBE,
 | 
					    POST_KIND_YOUTUBE(String),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl PostKind {
 | 
					impl PostKind {
 | 
				
			||||||
@@ -74,7 +74,7 @@ impl PostKind {
 | 
				
			|||||||
            PostKind::POST_KIND_MOVIE(_) => "movie",
 | 
					            PostKind::POST_KIND_MOVIE(_) => "movie",
 | 
				
			||||||
            PostKind::POST_KIND_COUNTDOWN(_) => "countdown",
 | 
					            PostKind::POST_KIND_COUNTDOWN(_) => "countdown",
 | 
				
			||||||
            PostKind::POST_KIND_SURVEY => "survey",
 | 
					            PostKind::POST_KIND_SURVEY => "survey",
 | 
				
			||||||
            PostKind::POST_KIND_YOUTUBE => "youtube",
 | 
					            PostKind::POST_KIND_YOUTUBE(_) => "youtube",
 | 
				
			||||||
        }.to_string()
 | 
					        }.to_string()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@
 | 
				
			|||||||
use crate::constants::database_tables_names::POSTS_TABLE;
 | 
					use crate::constants::database_tables_names::POSTS_TABLE;
 | 
				
			||||||
use crate::data::error::{ExecError, ResultBoxError};
 | 
					use crate::data::error::{ExecError, ResultBoxError};
 | 
				
			||||||
use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
 | 
					use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
 | 
				
			||||||
use crate::data::post::PostKind::{POST_KIND_COUNTDOWN, POST_KIND_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_SURVEY, POST_KIND_WEBLINK};
 | 
					use crate::data::post::PostKind::{POST_KIND_COUNTDOWN, POST_KIND_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_SURVEY, POST_KIND_WEBLINK, POST_KIND_YOUTUBE};
 | 
				
			||||||
use crate::data::user::UserID;
 | 
					use crate::data::user::UserID;
 | 
				
			||||||
use crate::helpers::{database, friends_helper};
 | 
					use crate::helpers::{database, friends_helper};
 | 
				
			||||||
use crate::utils::date_utils::time;
 | 
					use crate::utils::date_utils::time;
 | 
				
			||||||
@@ -176,6 +176,8 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        "sondage" => post.kind = POST_KIND_SURVEY,
 | 
					        "sondage" => post.kind = POST_KIND_SURVEY,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        "youtube" => post.kind = POST_KIND_YOUTUBE(res.get_str("path")?),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        _ => {}
 | 
					        _ => {}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user