mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Start to fetch page content
This commit is contained in:
@ -6,7 +6,6 @@ use crate::api_data::post_api::PostAPI;
|
||||
use crate::api_data::posts_targets_api::PostsTargets;
|
||||
use crate::api_data::res_create_post::ResCreatePost;
|
||||
use crate::constants::{PATH_POST_IMAGES, PATH_POST_PDF};
|
||||
use crate::routes::RequestResult;
|
||||
use crate::data::base_request_handler::BaseRequestHandler;
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
use crate::data::group::GroupAccessLevel;
|
||||
@ -15,9 +14,11 @@ use crate::data::new_survey::NewSurvey;
|
||||
use crate::data::notification::NotifEventType;
|
||||
use crate::data::post::{Post, PostAccessLevel, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
|
||||
use crate::helpers::{friends_helper, groups_helper, notifications_helper, posts_helper, survey_helper, user_helper};
|
||||
use crate::routes::RequestResult;
|
||||
use crate::utils::date_utils::time;
|
||||
use crate::utils::string_utils::{check_string_before_insert, check_youtube_id};
|
||||
use crate::utils::user_data_utils::user_data_path;
|
||||
use crate::utils::webpage_utils::get_post_web_link;
|
||||
|
||||
impl PostFile {
|
||||
/// Initialize a `PostFile` instance based on a file that have just been created
|
||||
@ -163,14 +164,18 @@ pub fn create_post(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let url = r.post_url_opt("url", true)?
|
||||
.ok_or(ExecError::new("Missing url!"))?;
|
||||
|
||||
// For now, for safety, we do not fetch page content
|
||||
// But this might change in the future
|
||||
PostKind::POST_KIND_WEBLINK(PostWebLink {
|
||||
url,
|
||||
title: None,
|
||||
description: None,
|
||||
image: None,
|
||||
})
|
||||
match get_post_web_link(&url) {
|
||||
Ok(info) => PostKind::POST_KIND_WEBLINK(info),
|
||||
Err(e) => {
|
||||
eprintln!("Error while fetching page metadata: {}", e);
|
||||
PostKind::POST_KIND_WEBLINK(PostWebLink {
|
||||
url,
|
||||
title: None,
|
||||
description: None,
|
||||
image: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"pdf" => {
|
||||
|
Reference in New Issue
Block a user