Skip to content

Commit 1188643

Browse files
committed
Remove user mention avatar helpers
1 parent 4b08c9a commit 1188643

5 files changed

Lines changed: 2 additions & 43 deletions

File tree

docs/api/models/users-members.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct User {
1717
}
1818
```
1919

20-
`Snowflake` is a type alias for `String`. Use `User::avatar_url()` to build a CDN URL from the hash, and `User::mention()` for `<@!id>`.
20+
`Snowflake` is a type alias for `String`. Inspect `avatar` and `id` directly when building UI links or message content.
2121

2222
## `Member`
2323

docs/zh/api/models/users-members.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct User {
1717
}
1818
```
1919

20-
`Snowflake``String` 的类型别名。`User::avatar_url()` 用哈希拼出 CDN 地址,`User::mention()` 返回 `<@!id>` 的 mention 串
20+
`Snowflake``String` 的类型别名。构造 UI 链接或消息内容时,直接检查 `avatar``id` 字段
2121

2222
## `Member`
2323

src/models/user/member.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ pub struct Member {
2222
pub mute: bool,
2323
}
2424

25-
impl Member {
26-
/// Gets the member's mention string.
27-
pub fn mention(&self) -> String {
28-
self.user.mention()
29-
}
30-
31-
/// Gets the member's avatar URL.
32-
pub fn avatar_url(&self) -> Option<String> {
33-
self.user.avatar_url()
34-
}
35-
}
36-
3725
impl HasId for Member {
3826
fn id(&self) -> Option<&Snowflake> {
3927
Some(&self.user.id)

src/models/user/model.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,6 @@ pub struct User {
2525
pub union_user_account: String,
2626
}
2727

28-
impl User {
29-
/// Gets the user's avatar URL if they have one.
30-
///
31-
/// Returns the full URL to the user's avatar image.
32-
pub fn avatar_url(&self) -> Option<String> {
33-
(!self.avatar.is_empty()).then(|| {
34-
format!(
35-
"https://thirdqq.qlogo.cn/headimg_dl?dst_uin={}&spec=640",
36-
self.id
37-
)
38-
})
39-
}
40-
41-
/// Gets the user's mention string.
42-
///
43-
/// Returns a string that can be used to mention this user in messages.
44-
pub fn mention(&self) -> String {
45-
format!("<@!{}>", self.id)
46-
}
47-
}
48-
4928
impl HasId for User {
5029
fn id(&self) -> Option<&Snowflake> {
5130
Some(&self.id)

src/models/user/tests.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fn user_uses_required_zero_value_fields() {
3232
assert!(!user.bot);
3333
assert_eq!(user.union_openid, "");
3434
assert_eq!(user.union_user_account, "");
35-
assert!(user.avatar_url().is_none());
3635
}
3736

3837
#[test]
@@ -53,7 +52,6 @@ fn user_keeps_official_json_shape() {
5352
assert_eq!(value["bot"], true);
5453
assert_eq!(value["union_openid"], "union-openid");
5554
assert_eq!(value["union_user_account"], "union-account");
56-
assert!(user.avatar_url().is_some());
5755
}
5856

5957
#[test]
@@ -77,12 +75,6 @@ fn user_from_bot_info_preserves_union_fields() {
7775
assert_eq!(user.union_user_account, "UNION_ACCOUNT_XXXXXX");
7876
}
7977

80-
#[test]
81-
fn test_user_mention() {
82-
let user = test_user("123456789", "TestUser");
83-
assert_eq!(user.mention(), "<@!123456789>");
84-
}
85-
8678
#[test]
8779
fn test_member_name_fallback() {
8880
let user = test_user("123456789", "TestUser");

0 commit comments

Comments
 (0)