Skip to main content

resolve_author_display

Function resolve_author_display 

Source
pub fn resolve_author_display(
    author_name: &str,
    author_email: &str,
    user_id: Option<i32>,
    user_display_name: Option<&str>,
    user_avatar_url: Option<&str>,
) -> (String, String, bool)
Expand description

解析评论的对外展示身份:(名称, 头像 URL, 是否作者)

user_id 非空(登录用户发表的评论)时,优先使用 JOIN users 得到的 实时显示名与头像——改名/换头像后历史评论自动跟随;匿名评论 (user_id 为 NULL)回退到评论行内快照名 + 邮箱 Gravatar。 返回的名称经 HTML 转义,与 author_name 列的存储口径一致。