mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 02:23:16 -06:00
fix up tests, add docs
This commit is contained in:
parent
28f89891d6
commit
e2d97c1ce7
33 changed files with 497 additions and 170 deletions
|
|
@ -25,26 +25,28 @@ import (
|
|||
|
||||
// Account represents the minimum viable representation of an account for export/import.
|
||||
type Account struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
Username string `json:"username"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
Username string `json:"username" bun:",nullzero"`
|
||||
Domain string `json:"domain,omitempty" bun:",nullzero"`
|
||||
HeaderRemoteURL string `json:"headerRemoteURL,omitempty" bun:",nullzero"`
|
||||
AvatarRemoteURL string `json:"avatarRemoteURL,omitempty" bun:",nullzero"`
|
||||
Locked bool `json:"locked"`
|
||||
Language string `json:"language,omitempty"`
|
||||
URI string `json:"uri"`
|
||||
URL string `json:"url"`
|
||||
InboxURI string `json:"inboxURI"`
|
||||
OutboxURI string `json:"outboxURI"`
|
||||
FollowingURI string `json:"followingUri"`
|
||||
FollowersURI string `json:"followersUri"`
|
||||
FeaturedCollectionURI string `json:"featuredCollectionUri"`
|
||||
ActorType string `json:"actorType"`
|
||||
Language string `json:"language,omitempty" bun:",nullzero"`
|
||||
URI string `json:"uri" bun:",nullzero"`
|
||||
URL string `json:"url" bun:",nullzero"`
|
||||
InboxURI string `json:"inboxURI" bun:",nullzero"`
|
||||
OutboxURI string `json:"outboxURI" bun:",nullzero"`
|
||||
FollowingURI string `json:"followingUri" bun:",nullzero"`
|
||||
FollowersURI string `json:"followersUri" bun:",nullzero"`
|
||||
FeaturedCollectionURI string `json:"featuredCollectionUri" bun:",nullzero"`
|
||||
ActorType string `json:"actorType" bun:",nullzero"`
|
||||
PrivateKey *rsa.PrivateKey `json:"-" mapstructure:"-"`
|
||||
PrivateKeyString string `json:"privateKey,omitempty" bun:"-" mapstructure:"privateKey"`
|
||||
PrivateKeyString string `json:"privateKey,omitempty" bun:"-" mapstructure:"privateKey" bun:",nullzero"`
|
||||
PublicKey *rsa.PublicKey `json:"-" mapstructure:"-"`
|
||||
PublicKeyString string `json:"publicKey,omitempty" bun:"-" mapstructure:"publicKey"`
|
||||
PublicKeyURI string `json:"publicKeyUri"`
|
||||
SuspendedAt *time.Time `json:"suspendedAt,omitempty"`
|
||||
PublicKeyString string `json:"publicKey,omitempty" bun:"-" mapstructure:"publicKey" bun:",nullzero"`
|
||||
PublicKeyURI string `json:"publicKeyUri" bun:",nullzero"`
|
||||
SuspendedAt *time.Time `json:"suspendedAt,omitempty" bun:",nullzero"`
|
||||
SuspensionOrigin string `json:"suspensionOrigin,omitempty" bun:",nullzero"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ package trans
|
|||
|
||||
import "time"
|
||||
|
||||
// Block represents an account block as serialized in an exported file.
|
||||
type Block struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
URI string `json:"uri"`
|
||||
AccountID string `json:"accountId"`
|
||||
TargetAccountID string `json:"targetAccountId"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
URI string `json:"uri" bun:",nullzero"`
|
||||
AccountID string `json:"accountId" bun:",nullzero"`
|
||||
TargetAccountID string `json:"targetAccountId" bun:",nullzero"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,15 @@ package trans
|
|||
|
||||
import "time"
|
||||
|
||||
// DomainBlock represents a domain block as serialized in an exported file.
|
||||
type DomainBlock struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
CreatedByAccountID string `json:"createdByAccountID"`
|
||||
PrivateComment string `json:"privateComment,omitempty"`
|
||||
PublicComment string `json:"publicComment,omitempty"`
|
||||
Obfuscate bool `json:"obfuscate"`
|
||||
SubscriptionID string `json:"subscriptionID,omitempty"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
Domain string `json:"domain" bun:",nullzero"`
|
||||
CreatedByAccountID string `json:"createdByAccountID" bun:",nullzero"`
|
||||
PrivateComment string `json:"privateComment,omitempty" bun:",nullzero"`
|
||||
PublicComment string `json:"publicComment,omitempty" bun:",nullzero"`
|
||||
Obfuscate bool `json:"obfuscate" bun:",nullzero"`
|
||||
SubscriptionID string `json:"subscriptionID,omitempty" bun:",nullzero"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ package trans
|
|||
|
||||
import "time"
|
||||
|
||||
// Follow represents an account follow as serialized in an export file.
|
||||
type Follow struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
URI string `json:"uri"`
|
||||
AccountID string `json:"accountId"`
|
||||
TargetAccountID string `json:"targetAccountId"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
URI string `json:"uri" bun:",nullzero"`
|
||||
AccountID string `json:"accountId" bun:",nullzero"`
|
||||
TargetAccountID string `json:"targetAccountId" bun:",nullzero"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ package trans
|
|||
|
||||
import "time"
|
||||
|
||||
// FollowRequest represents an account follow request as serialized in an export file.
|
||||
type FollowRequest struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
URI string `json:"uri"`
|
||||
AccountID string `json:"accountId"`
|
||||
TargetAccountID string `json:"targetAccountId"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
URI string `json:"uri" bun:",nullzero"`
|
||||
AccountID string `json:"accountId" bun:",nullzero"`
|
||||
TargetAccountID string `json:"targetAccountId" bun:",nullzero"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,14 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Instance represents an instance entry as serialized in an export file.
|
||||
type Instance struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
Domain string `json:"domain"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
Domain string `json:"domain" bun:",nullzero"`
|
||||
Title string `json:"title,omitempty" bun:",nullzero"`
|
||||
URI string `json:"uri"`
|
||||
URI string `json:"uri" bun:",nullzero"`
|
||||
SuspendedAt *time.Time `json:"suspendedAt,omitempty" bun:",nullzero"`
|
||||
DomainBlockID string `json:"domainBlockID,omitempty" bun:",nullzero"`
|
||||
ShortDescription string `json:"shortDescription,omitempty" bun:",nullzero"`
|
||||
|
|
|
|||
|
|
@ -18,21 +18,24 @@
|
|||
|
||||
package trans
|
||||
|
||||
// TypeKey should be set on a TransEntry to indicate the type of entry it is.
|
||||
const TypeKey = "type"
|
||||
|
||||
// TransType describes the type of a trans entry, and how it should be read/serialized.
|
||||
type TransType string
|
||||
// Type describes the type of a trans entry, and how it should be read/serialized.
|
||||
type Type string
|
||||
|
||||
// Type of the trans entry. Describes how it should be read from file.
|
||||
const (
|
||||
TransAccount TransType = "account"
|
||||
TransBlock TransType = "block"
|
||||
TransDomainBlock TransType = "domainBlock"
|
||||
TransEmailDomainBlock TransType = "emailDomainBlock"
|
||||
TransFollow TransType = "follow"
|
||||
TransFollowRequest TransType = "followRequest"
|
||||
TransInstance TransType = "instance"
|
||||
TransUser TransType = "user"
|
||||
TransAccount Type = "account"
|
||||
TransBlock Type = "block"
|
||||
TransDomainBlock Type = "domainBlock"
|
||||
TransEmailDomainBlock Type = "emailDomainBlock"
|
||||
TransFollow Type = "follow"
|
||||
TransFollowRequest Type = "followRequest"
|
||||
TransInstance Type = "instance"
|
||||
TransUser Type = "user"
|
||||
)
|
||||
|
||||
type TransEntry map[string]interface{}
|
||||
// Entry is used for deserializing trans entries into a rough interface so that
|
||||
// the TypeKey can be fetched, before continuing with full parsing.
|
||||
type Entry map[string]interface{}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,14 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// User represents a local instance user as serialized to an export file.
|
||||
type User struct {
|
||||
Type TransType `json:"type" bun:"-"`
|
||||
ID string `json:"id"`
|
||||
CreatedAt *time.Time `json:"createdAt"`
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
Email string `json:"email,omitempty" bun:",nullzero"`
|
||||
AccountID string `json:"accountID"`
|
||||
EncryptedPassword string `json:"encryptedPassword"`
|
||||
AccountID string `json:"accountID" bun:",nullzero"`
|
||||
EncryptedPassword string `json:"encryptedPassword" bun:",nullzero"`
|
||||
CurrentSignInAt *time.Time `json:"currentSignInAt,omitempty" bun:",nullzero"`
|
||||
LastSignInAt *time.Time `json:"lastSignInAt,omitempty" bun:",nullzero"`
|
||||
InviteID string `json:"inviteID,omitempty" bun:",nullzero"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue