OmitEmpty in JSON.
This commit is contained in:
parent
6e58f4a0b5
commit
8e27a857a9
@ -16,34 +16,34 @@ import (
|
|||||||
|
|
||||||
// PublicKey : Activity Certificate.
|
// PublicKey : Activity Certificate.
|
||||||
type PublicKey struct {
|
type PublicKey struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id,omitempty"`
|
||||||
Owner string `json:"owner"`
|
Owner string `json:"owner,omitempty"`
|
||||||
PublicKeyPem string `json:"publicKeyPem"`
|
PublicKeyPem string `json:"publicKeyPem,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//Endpoints : Contains SharedInbox address.
|
//Endpoints : Contains SharedInbox address.
|
||||||
type Endpoints struct {
|
type Endpoints struct {
|
||||||
SharedInbox string `json:"sharedInbox"`
|
SharedInbox string `json:"sharedInbox,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image : Image Object.
|
// Image : Image Object.
|
||||||
type Image struct {
|
type Image struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actor : ActivityPub Actor.
|
// Actor : ActivityPub Actor.
|
||||||
type Actor struct {
|
type Actor struct {
|
||||||
Context interface{} `json:"@context"`
|
Context interface{} `json:"@context,omitempty"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id,omitempty"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name,omitempty"`
|
||||||
PreferredUsername string `json:"preferredUsername"`
|
PreferredUsername string `json:"preferredUsername,omitempty"`
|
||||||
Summary string `json:"summary"`
|
Summary string `json:"summary,omitempty"`
|
||||||
Inbox string `json:"inbox"`
|
Inbox string `json:"inbox,omitempty"`
|
||||||
Endpoints *Endpoints `json:"endpoints"`
|
Endpoints *Endpoints `json:"endpoints,omitempty"`
|
||||||
PublicKey PublicKey `json:"publicKey"`
|
PublicKey PublicKey `json:"publicKey,omitempty"`
|
||||||
Icon Image `json:"icon"`
|
Icon Image `json:"icon,omitempty"`
|
||||||
Image Image `json:"image"`
|
Image Image `json:"image,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateSelfKey : Generate relay Actor from Publickey.
|
// GenerateSelfKey : Generate relay Actor from Publickey.
|
||||||
@ -93,13 +93,13 @@ func (actor *Actor) RetrieveRemoteActor(url string, uaString string, cache *cach
|
|||||||
|
|
||||||
// Activity : ActivityPub Activity.
|
// Activity : ActivityPub Activity.
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
Context interface{} `json:"@context"`
|
Context interface{} `json:"@context,omitempty"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id,omitempty"`
|
||||||
Actor string `json:"actor"`
|
Actor string `json:"actor,omitempty"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Object interface{} `json:"object"`
|
Object interface{} `json:"object,omitempty"`
|
||||||
To []string `json:"to"`
|
To []string `json:"to,omitempty"`
|
||||||
Cc []string `json:"cc"`
|
Cc []string `json:"cc,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateResponse : Generate activity response.
|
// GenerateResponse : Generate activity response.
|
||||||
@ -161,33 +161,33 @@ func (activity *Activity) NestedActivity() (*Activity, error) {
|
|||||||
|
|
||||||
// ActivityObject : ActivityPub Activity.
|
// ActivityObject : ActivityPub Activity.
|
||||||
type ActivityObject struct {
|
type ActivityObject struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id,omitempty"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name,omitempty"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content,omitempty"`
|
||||||
To []string `json:"to"`
|
To []string `json:"to,omitempty"`
|
||||||
Cc []string `json:"cc"`
|
Cc []string `json:"cc,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signature : ActivityPub Header Signature.
|
// Signature : ActivityPub Header Signature.
|
||||||
type Signature struct {
|
type Signature struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Creator string `json:"creator"`
|
Creator string `json:"creator,omitempty"`
|
||||||
Created string `json:"created"`
|
Created string `json:"created,omitempty"`
|
||||||
SignatureValue string `json:"signatureValue"`
|
SignatureValue string `json:"signatureValue,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebfingerLink : Webfinger Link Resource.
|
// WebfingerLink : Webfinger Link Resource.
|
||||||
type WebfingerLink struct {
|
type WebfingerLink struct {
|
||||||
Rel string `json:"rel"`
|
Rel string `json:"rel,omitempty"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Href string `json:"href"`
|
Href string `json:"href,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebfingerResource : Webfinger Resource.
|
// WebfingerResource : Webfinger Resource.
|
||||||
type WebfingerResource struct {
|
type WebfingerResource struct {
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject,omitempty"`
|
||||||
Links []WebfingerLink `json:"links"`
|
Links []WebfingerLink `json:"links,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateFromActor : Generate Webfinger resource from Actor.
|
// GenerateFromActor : Generate Webfinger resource from Actor.
|
||||||
|
@ -31,10 +31,10 @@ func NewState(redisClient *redis.Client) RelayState {
|
|||||||
type RelayState struct {
|
type RelayState struct {
|
||||||
RedisClient *redis.Client
|
RedisClient *redis.Client
|
||||||
|
|
||||||
RelayConfig relayConfig `json:"relayConfig"`
|
RelayConfig relayConfig `json:"relayConfig,omitempty"`
|
||||||
LimitedDomains []string `json:"limitedDomains"`
|
LimitedDomains []string `json:"limitedDomains,omitempty"`
|
||||||
BlockedDomains []string `json:"blockedDomains"`
|
BlockedDomains []string `json:"blockedDomains,omitempty"`
|
||||||
Subscriptions []Subscription `json:"subscriptions"`
|
Subscriptions []Subscription `json:"subscriptions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load : Refrash content from redis
|
// Load : Refrash content from redis
|
||||||
@ -140,16 +140,16 @@ func (config *RelayState) SetLimitedDomain(domain string, value bool) {
|
|||||||
|
|
||||||
// Subscription : Instance subscription information
|
// Subscription : Instance subscription information
|
||||||
type Subscription struct {
|
type Subscription struct {
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain,omitempty"`
|
||||||
InboxURL string `json:"inbox_url"`
|
InboxURL string `json:"inbox_url,omitempty"`
|
||||||
ActivityID string `json:"activity_id"`
|
ActivityID string `json:"activity_id,omitempty"`
|
||||||
ActorID string `json:"actor_id"`
|
ActorID string `json:"actor_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type relayConfig struct {
|
type relayConfig struct {
|
||||||
BlockService bool `json:"blockService"`
|
BlockService bool `json:"blockService,omitempty"`
|
||||||
ManuallyAccept bool `json:"manuallyAccept"`
|
ManuallyAccept bool `json:"manuallyAccept,omitempty"`
|
||||||
CreateAsAnnounce bool `json:"createAsAnnounce"`
|
CreateAsAnnounce bool `json:"createAsAnnounce,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *relayConfig) load(redisClient *redis.Client) {
|
func (config *relayConfig) load(redisClient *redis.Client) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"RedisClient":{},"relayConfig":{"blockService":false,"manuallyAccept":false,"createAsAnnounce":false},"limitedDomains":null,"blockedDomains":null,"subscriptions":null}
|
{"RedisClient":{},"relayConfig":{}}
|
Loading…
x
Reference in New Issue
Block a user