1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Add post with weblink support

This commit is contained in:
2020-07-03 10:18:26 +02:00
parent a359b6656f
commit 689cf07ee4
3 changed files with 45 additions and 11 deletions

View File

@ -4,8 +4,8 @@
use crate::constants::database_tables_names::POSTS_TABLE;
use crate::data::error::{ExecError, ResultBoxError};
use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel};
use crate::data::post::PostKind::POST_KIND_IMAGE;
use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
use crate::data::post::PostKind::{POST_KIND_IMAGE, POST_KIND_WEBLINK};
use crate::data::user::UserID;
use crate::helpers::{database, friends_helper};
use crate::utils::date_utils::time;
@ -161,6 +161,13 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
match res.get_str("type")?.as_str() {
"image" => post.kind = POST_KIND_IMAGE(file?),
"webpage_link" => post.kind = POST_KIND_WEBLINK(PostWebLink {
url: res.get_str("url_page")?,
title: res.get_optional_str("titre_page")?,
description: res.get_optional_str("description_page")?,
image: res.get_optional_str("image_page")?,
}),
_ => {}
}