backend for xcvr appview
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

add marshalJSON methods for views

rachel-mp4 852bfeb0 ef88444c

+59 -1
+59 -1
server/internal/types/lexicons.go
··· 1 1 package types 2 2 3 - import "time" 3 + import ( 4 + "encoding/json" 5 + "time" 6 + ) 4 7 5 8 type Profile struct { 6 9 DID string ··· 32 35 DefaultNick *string `json:"defaultNick,omitempty"` 33 36 } 34 37 38 + func (p ProfileView) MarshalJSON() ([]byte, error) { 39 + type Alias ProfileView 40 + return json.Marshal(&struct { 41 + Type string `json:"$type"` 42 + *Alias 43 + }{ 44 + Type: "org.xcvr.actor.defs#profileView", 45 + Alias: (*Alias)(&p), 46 + }) 47 + } 48 + 35 49 type DIDHandle struct { 36 50 Handle string 37 51 DID string ··· 82 96 CreatedAt time.Time `json:"createdAt"` 83 97 } 84 98 99 + func (c ChannelView) MarshalJSON() ([]byte, error) { 100 + type Alias ChannelView 101 + return json.Marshal(&struct { 102 + Type string `json:"$type"` 103 + *Alias 104 + }{ 105 + Type: "org.xcvr.feed.defs#channelView", 106 + Alias: (*Alias)(&c), 107 + }) 108 + } 109 + 85 110 type Signet struct { 86 111 URI string 87 112 IssuerDID string ··· 103 128 StartedAt time.Time `json:"startedAt"` 104 129 } 105 130 131 + func (s SignetView) MarshalJSON() ([]byte, error) { 132 + type Alias SignetView 133 + return json.Marshal(&struct { 134 + Type string `json:"$type"` 135 + *Alias 136 + }{ 137 + Type: "org.xcvr.lrc.defs#signetView", 138 + Alias: (*Alias)(&s), 139 + }) 140 + } 141 + 106 142 type Message struct { 107 143 URI string 108 144 DID string ··· 136 172 PostedAt time.Time `json:"postedAt"` 137 173 } 138 174 175 + func (m MessageView) MarshalJSON() ([]byte, error) { 176 + type Alias MessageView 177 + return json.Marshal(&struct { 178 + Type string `json:"$type"` 179 + *Alias 180 + }{ 181 + Type: "org.xcvr.lrc.defs#messageView", 182 + Alias: (*Alias)(&m), 183 + }) 184 + } 185 + 139 186 type SignedMessageView struct { 140 187 Type string `json:"$type,const=org.xcvr.lrc.defs#signedMessageView"` 141 188 URI string `json:"uri"` ··· 145 192 Color *uint32 `json:"color,omitempty"` 146 193 Signet SignetView `json:"signet"` 147 194 PostedAt time.Time `json:"postedAt"` 195 + } 196 + 197 + func (m SignedMessageView) MarshalJSON() ([]byte, error) { 198 + type Alias SignedMessageView 199 + return json.Marshal(&struct { 200 + Type string `json:"$type"` 201 + *Alias 202 + }{ 203 + Type: "org.xcvr.lrc.defs#signedMessageView", 204 + Alias: (*Alias)(&m), 205 + }) 148 206 } 149 207 150 208 type GetMessagesOut struct {