#[macro_export]
macro_rules! check_user_is_blocked {
    (($data:ident, $tera:ident, $build_code:ident), $user:ident, $juser:ident, $profile:ident) => {
        let is_blocked = if let Some(ref ua) = $user {
            $data
                .get_juicespace_block_by_initiator_receiver($profile.0.id, ua.id)
                .await
                .is_ok()
        } else {
            false
        };

        if is_blocked {
            return $crate::routes::pages::misc::render_error(
                Error::NotAllowed,
                $data,
                $tera,
                $build_code,
                &$user,
                &$juser,
            );
        }
    };

    (($data:ident, $tera:ident, $build_code:ident), $user:ident, $juser:ident, $profile:ident <> Result::Ok) => {
        let is_blocked = if let Some(ref ua) = $user {
            $data
                .get_juicespace_block_by_initiator_receiver($profile.0.id, ua.id)
                .await
                .is_ok()
        } else {
            false
        };

        if is_blocked {
            return Ok($crate::routes::pages::misc::render_error(
                Error::NotAllowed,
                $data,
                $tera,
                $build_code,
                &$user,
                &$juser,
            ));
        }
    };

    (($data:ident, $tera:ident, $build_code:ident), user := $user:ident, juser := $juser:ident, $profile:ident) => {
        let is_blocked = $data
            .get_juicespace_block_by_initiator_receiver($profile.0.id, $user.id)
            .await
            .is_ok();

        if is_blocked {
            return $crate::routes::pages::misc::render_error(
                Error::NotAllowed,
                $data,
                $tera,
                $build_code,
                &Some($user),
                &Some($juser),
            );
        }
    };
}

#[macro_export]
macro_rules! check_user_is_private_and_following {
    ($data:ident, $ua:expr, $profile:expr) => {
        if let Some(ref ua) = $ua {
            ua.id == $profile.id
                || $data
                    .get_user_follow_by_initiator_receiver(&$profile.id, &ua.id)
                    .await
                    .is_ok()
        } else {
            false
        }
    };
}
