Skip to content

Commit

Permalink
Merge pull request #1120 from paultyng/status_emoji_display_info
Browse files Browse the repository at this point in the history
Add support for status_emoji_display_info
  • Loading branch information
kanata2 authored Nov 4, 2022
2 parents f1c8f0a + 048adff commit df7caaf
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 38 deletions.
56 changes: 32 additions & 24 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,38 @@ const (

// UserProfile contains all the information details of a given user
type UserProfile struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
RealName string `json:"real_name"`
RealNameNormalized string `json:"real_name_normalized"`
DisplayName string `json:"display_name"`
DisplayNameNormalized string `json:"display_name_normalized"`
Email string `json:"email"`
Skype string `json:"skype"`
Phone string `json:"phone"`
Image24 string `json:"image_24"`
Image32 string `json:"image_32"`
Image48 string `json:"image_48"`
Image72 string `json:"image_72"`
Image192 string `json:"image_192"`
Image512 string `json:"image_512"`
ImageOriginal string `json:"image_original"`
Title string `json:"title"`
BotID string `json:"bot_id,omitempty"`
ApiAppID string `json:"api_app_id,omitempty"`
StatusText string `json:"status_text,omitempty"`
StatusEmoji string `json:"status_emoji,omitempty"`
StatusExpiration int `json:"status_expiration"`
Team string `json:"team"`
Fields UserProfileCustomFields `json:"fields"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
RealName string `json:"real_name"`
RealNameNormalized string `json:"real_name_normalized"`
DisplayName string `json:"display_name"`
DisplayNameNormalized string `json:"display_name_normalized"`
Email string `json:"email"`
Skype string `json:"skype"`
Phone string `json:"phone"`
Image24 string `json:"image_24"`
Image32 string `json:"image_32"`
Image48 string `json:"image_48"`
Image72 string `json:"image_72"`
Image192 string `json:"image_192"`
Image512 string `json:"image_512"`
ImageOriginal string `json:"image_original"`
Title string `json:"title"`
BotID string `json:"bot_id,omitempty"`
ApiAppID string `json:"api_app_id,omitempty"`
StatusText string `json:"status_text,omitempty"`
StatusEmoji string `json:"status_emoji,omitempty"`
StatusEmojiDisplayInfo []UserProfileStatusEmojiDisplayInfo `json:"status_emoji_display_info,omitempty"`
StatusExpiration int `json:"status_expiration"`
Team string `json:"team"`
Fields UserProfileCustomFields `json:"fields"`
}

type UserProfileStatusEmojiDisplayInfo struct {
EmojiName string `json:"emoji_name"`
DisplayAlias string `json:"display_alias,omitempty"`
DisplayURL string `json:"display_url,omitempty"`
Unicode string `json:"unicode,omitempty"`
}

// UserProfileCustomFields represents user profile's custom fields.
Expand Down
40 changes: 26 additions & 14 deletions users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,31 @@ func getTestUserProfileCustomFields() UserProfileCustomFields {
}}
}

func getTestUserProfileStatusEmojiDisplayInfo() []UserProfileStatusEmojiDisplayInfo {
return []UserProfileStatusEmojiDisplayInfo{{
EmojiName: "construction",
Unicode: "1f6a7",
DisplayURL: "https://a.slack-edge.com/production-standard-emoji-assets/14.0/apple-large/1f6a7.png",
}}
}

func getTestUserProfile() UserProfile {
return UserProfile{
StatusText: "testStatus",
StatusEmoji: ":construction:",
RealName: "Test Real Name",
RealNameNormalized: "Test Real Name Normalized",
DisplayName: "Test Display Name",
DisplayNameNormalized: "Test Display Name Normalized",
Email: "test@test.com",
Image24: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_24.jpg",
Image32: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_32.jpg",
Image48: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_48.jpg",
Image72: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_72.jpg",
Image192: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_192.jpg",
Image512: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_512.jpg",
Fields: getTestUserProfileCustomFields(),
StatusText: "testStatus",
StatusEmoji: ":construction:",
StatusEmojiDisplayInfo: getTestUserProfileStatusEmojiDisplayInfo(),
RealName: "Test Real Name",
RealNameNormalized: "Test Real Name Normalized",
DisplayName: "Test Display Name",
DisplayNameNormalized: "Test Display Name Normalized",
Email: "test@test.com",
Image24: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_24.jpg",
Image32: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_32.jpg",
Image48: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_48.jpg",
Image72: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_72.jpg",
Image192: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_192.jpg",
Image512: "https://s3-us-west-2.amazonaws.com/slack-files2/avatars/2016-10-18/92962080834_ef14c1469fc0741caea1_512.jpg",
Fields: getTestUserProfileCustomFields(),
}
}

Expand Down Expand Up @@ -608,6 +617,9 @@ func TestGetUserProfile(t *testing.T) {
if profile.DisplayName != exp.DisplayName {
t.Fatalf(`profile.DisplayName = "%s", wanted "%s"`, profile.DisplayName, exp.DisplayName)
}
if len(profile.StatusEmojiDisplayInfo) != 1 {
t.Fatalf(`expected 1 emoji, got %d`, len(profile.StatusEmojiDisplayInfo))
}
}

func TestSetFieldsMap(t *testing.T) {
Expand Down

0 comments on commit df7caaf

Please sign in to comment.