2022-08-02 12:56:26 +00:00
|
|
|
package identity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2023-03-13 14:30:19 +00:00
|
|
|
"reflect"
|
2022-08-02 12:56:26 +00:00
|
|
|
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
)
|
|
|
|
|
|
|
|
// static links which need to be decorated by the UI clients
|
|
|
|
const (
|
|
|
|
TwitterID = "__twitter"
|
|
|
|
PersonalSiteID = "__personal_site"
|
|
|
|
GithubID = "__github"
|
|
|
|
YoutubeID = "__youtube"
|
|
|
|
DiscordID = "__discord"
|
|
|
|
TelegramID = "__telegram"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SocialLink struct {
|
|
|
|
Text string `json:"text"`
|
|
|
|
URL string `json:"url"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type SocialLinks []SocialLink
|
|
|
|
|
|
|
|
func NewSocialLinks(links []*protobuf.SocialLink) *SocialLinks {
|
|
|
|
res := SocialLinks{}
|
|
|
|
for _, link := range links {
|
|
|
|
res = append(res, SocialLink{Text: link.Text, URL: link.Url})
|
|
|
|
}
|
|
|
|
return &res
|
|
|
|
}
|
|
|
|
|
2022-08-11 14:11:28 +00:00
|
|
|
func (s *SocialLinks) ToProtobuf() []*protobuf.SocialLink {
|
2022-08-02 12:56:26 +00:00
|
|
|
res := []*protobuf.SocialLink{}
|
|
|
|
for _, link := range *s {
|
|
|
|
res = append(res, &protobuf.SocialLink{Text: link.Text, Url: link.URL})
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s SocialLinks) Equals(rhs SocialLinks) bool {
|
2023-03-13 14:30:19 +00:00
|
|
|
return reflect.DeepEqual(s, rhs)
|
2022-08-02 12:56:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *SocialLinks) Serialize() ([]byte, error) {
|
|
|
|
return json.Marshal(s)
|
|
|
|
}
|