status-go/protocol/identity/social_links.go

51 lines
1.1 KiB
Go
Raw Normal View History

2022-08-02 12:56:26 +00:00
package identity
import (
"encoding/json"
"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"`
Clock uint64 `json:"clock"`
2022-08-02 12:56:26 +00:00
}
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
}
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 {
return reflect.DeepEqual(s, rhs)
2022-08-02 12:56:26 +00:00
}
func (s *SocialLinks) Serialize() ([]byte, error) {
return json.Marshal(s)
}