diff --git a/meta/member.go b/meta/member.go new file mode 100644 index 0000000..694acce --- /dev/null +++ b/meta/member.go @@ -0,0 +1,54 @@ +package meta + +import ( + "image/color" + "time" +) + +// Common holds profile fields common between [System] and [Member]. +type Common struct { + // Display name. + Name string `json:"name"` + // Optional description text, uninterpreted. + Description string `json:"description,omitempty"` + // Optional preferred pronouns, uninterpreted. + Pronouns string `json:"pronouns,omitempty"` + // Profile picture. The zero value implies the system profile picture. + Picture *URL `json:"picture,omitempty"` + // Optional preferred accent color. + Color *color.CMYK `json:"color,omitempty"` + + // TODO(ophestra): pluralkit fields represented separately: + // id + // uuid + // created + // TODO(ophestra): unimplemented pluralkit fields: + // banner + // privacy +} + +// Member describes a system member. +type Member struct { + Common + + // Mutable short name, unique to the [System]. + Handle string `json:"handle"` + // Optional preferred birthday. + Birthday time.Time `json:"birthday,omitempty"` + + // TODO(ophestra): unimplemented pluralkit fields: + // keep_proxy + // tts + // autoproxy_enabled + // message_count + // last_message_timestamp + // proxy_tags +} + +// System describes a system and its members. +type System struct { + Common + + // TODO(ophestra): unimplemented pluralkit fields: + // tag +} diff --git a/meta/meta.go b/meta/meta.go new file mode 100644 index 0000000..84e1410 --- /dev/null +++ b/meta/meta.go @@ -0,0 +1,20 @@ +// Package meta defines system and member metadata types. +package meta + +import ( + "encoding" + "net/url" +) + +// URL implements [encoding] interfaces on top of [url.URL]. +type URL struct{ url.URL } + +var ( + _ encoding.TextAppender = new(URL) + _ encoding.TextMarshaler = new(URL) + _ encoding.TextUnmarshaler = new(URL) +) + +func (u *URL) MarshalText() (data []byte, err error) { return u.MarshalBinary() } +func (u *URL) AppendText(data []byte) ([]byte, error) { return u.AppendBinary(data) } +func (u *URL) UnmarshalText(data []byte) error { return u.UnmarshalBinary(data) }