pub fn modify_post(
        edit_post_changeset: EditPostChangeset,
        thread_uuid: ThreadUuid,
        user_uuid: UserUuid,
        conn: &PgConnection,
    ) -> BackendResult<ChildlessPostData> {
        //        use schema::posts;

        let target_thread: Thread = Thread::get_thread(thread_uuid, conn)?;
        if target_thread.locked || target_thread.archived {
            return Err(Error::ThreadImmutable);
        }

        let modified_post: Post = edit_post_changeset.save_changes(conn).map_err(handle_err::<Post>)?;

        let votes: VoteCounts = Post::get_vote_counts(&modified_post, user_uuid, conn)?;

        let author_uuid = UserUuid(modified_post.author_uuid);
        let user = User::get_user(author_uuid, conn)?;
        Ok(ChildlessPostData {
            post: modified_post,
            user,
            votes,
        })
    }
/// Applies the EditPostChangeset to the post.
/// If the thread is locked, the post cannot be modified
Applies the EditPostChangeset to the post.
If the thread is locked, the post cannot be modified
Applies the EditPostChangeset to the post . If the thread is locked the post cannot be modified
pub fn modify_post(
        edit_post_changeset: EditPostChangeset,
        thread_uuid: ThreadUuid,
        user_uuid: UserUuid,
        conn: &PgConnection,
    ) -> BackendResult<ChildlessPostData> {
        //        use schema::posts;
        let target_thread: Thread = Thread::get_thread(thread_uuid, conn)?;
        if target_thread.locked || target_thread.archived {
            return Err(Error::ThreadImmutable);
        }
        let modified_post: Post = edit_post_changeset.save_changes(conn).map_err(handle_err::<Post>)?;
        let votes: VoteCounts = Post::get_vote_counts(&modified_post, user_uuid, conn)?;
        let author_uuid = UserUuid(modified_post.author_uuid);
        let user = User::get_user(author_uuid, conn)?;
        Ok(ChildlessPostData {
            post: modified_post,
            user,
            votes,
        })
    }
pub fn modify_post ( edit_post_changeset : EditPostChangeset , thread_uuid : ThreadUuid , user_uuid : UserUuid , conn : & PgConnection , ) -> BackendResult < ChildlessPostData > { //        use schema::posts; let target_thread : Thread = Thread :: get_thread ( thread_uuid , conn ) ? ; if target_thread . locked || target_thread . archived { return Err ( Error :: ThreadImmutable ) ; } let modified_post : Post = edit_post_changeset . save_changes ( conn ) . map_err ( handle_err :: < Post > ) ? ; let votes : VoteCounts = Post :: get_vote_counts ( & modified_post , user_uuid , conn ) ? ; let author_uuid = UserUuid ( modified_post . author_uuid ) ; let user = User :: get_user ( author_uuid , conn ) ? ; Ok ( ChildlessPostData { post : modified_post , user , votes , } ) }
Applies the EditPostChangeset to the post.
Applies the EditPostChangeset to the post .
edit_post_changeset
EditPostChangeset
thread_uuid
ThreadUuid
user_uuid
UserUuid
conn
&PgConnection
edit_post_changeset
EditPostChangeset
thread_uuid
ThreadUuid
user_uuid
UserUuid
conn
&PgConnection