mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-14 17:17:29 -06:00
Import export (#194)
* start with export/import code * messing about with decoding/encoding * some more fiddling * stuff is WORKING * working pretty alright! * go fmt * fix up tests, add docs * start backup/restore doc * tweaks * credits * update advancedVisibility settings * update bun library -> v1.0.4 Signed-off-by: kim (grufwub) <grufwub@gmail.com> * update oauth library -> v4.3.1-SSB Signed-off-by: kim (grufwub) <grufwub@gmail.com> * handle oauth token scope, fix user.SigninCount + token.UserID Signed-off-by: kim (grufwub) <grufwub@gmail.com> * update oauth library --> v4.3.2-SSB Signed-off-by: kim (grufwub) <grufwub@gmail.com> * update sqlite library -> v1.13.0 Signed-off-by: kim (grufwub) <grufwub@gmail.com> * review changes * start with export/import code * messing about with decoding/encoding * some more fiddling * stuff is WORKING * working pretty alright! * go fmt * fix up tests, add docs * start backup/restore doc * tweaks * credits * update advancedVisibility settings * review changes Co-authored-by: kim (grufwub) <grufwub@gmail.com> Co-authored-by: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>
This commit is contained in:
parent
a027da0ac9
commit
555ea8edfb
61 changed files with 4031 additions and 250 deletions
54
internal/trans/model/account.go
Normal file
54
internal/trans/model/account.go
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Account represents the minimum viable representation of an account for export/import.
|
||||
type Account struct {
|
||||
Type Type `json:"type" bun:"-"`
|
||||
ID string `json:"id" bun:",nullzero"`
|
||||
CreatedAt *time.Time `json:"createdAt" bun:",nullzero"`
|
||||
Username string `json:"username" bun:",nullzero"`
|
||||
DisplayName string `json:"displayName,omitempty" bun:",nullzero"`
|
||||
Note string `json:"note,omitempty" 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" 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" mapstructure:"privateKey" bun:"-"`
|
||||
PublicKey *rsa.PublicKey `json:"-" mapstructure:"-"`
|
||||
PublicKeyString string `json:"publicKey,omitempty" mapstructure:"publicKey" bun:"-"`
|
||||
PublicKeyURI string `json:"publicKeyUri" bun:",nullzero"`
|
||||
SuspendedAt *time.Time `json:"suspendedAt,omitempty" bun:",nullzero"`
|
||||
SuspensionOrigin string `json:"suspensionOrigin,omitempty" bun:",nullzero"`
|
||||
}
|
||||
31
internal/trans/model/block.go
Normal file
31
internal/trans/model/block.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import "time"
|
||||
|
||||
// Block represents an account block as serialized in an exported file.
|
||||
type Block struct {
|
||||
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"`
|
||||
}
|
||||
34
internal/trans/model/domainblock.go
Normal file
34
internal/trans/model/domainblock.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import "time"
|
||||
|
||||
// DomainBlock represents a domain block as serialized in an exported file.
|
||||
type DomainBlock struct {
|
||||
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"`
|
||||
}
|
||||
31
internal/trans/model/follow.go
Normal file
31
internal/trans/model/follow.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import "time"
|
||||
|
||||
// Follow represents an account follow as serialized in an export file.
|
||||
type Follow struct {
|
||||
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"`
|
||||
}
|
||||
31
internal/trans/model/followrequest.go
Normal file
31
internal/trans/model/followrequest.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import "time"
|
||||
|
||||
// FollowRequest represents an account follow request as serialized in an export file.
|
||||
type FollowRequest struct {
|
||||
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"`
|
||||
}
|
||||
43
internal/trans/model/instance.go
Normal file
43
internal/trans/model/instance.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Instance represents an instance entry as serialized in an export file.
|
||||
type Instance struct {
|
||||
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" bun:",nullzero"`
|
||||
SuspendedAt *time.Time `json:"suspendedAt,omitempty" bun:",nullzero"`
|
||||
DomainBlockID string `json:"domainBlockID,omitempty" bun:",nullzero"`
|
||||
ShortDescription string `json:"shortDescription,omitempty" bun:",nullzero"`
|
||||
Description string `json:"description,omitempty" bun:",nullzero"`
|
||||
Terms string `json:"terms,omitempty" bun:",nullzero"`
|
||||
ContactEmail string `json:"contactEmail,omitempty" bun:",nullzero"`
|
||||
ContactAccountUsername string `json:"contactAccountUsername,omitempty" bun:",nullzero"`
|
||||
ContactAccountID string `json:"contactAccountID,omitempty" bun:",nullzero"`
|
||||
Reputation int64 `json:"reputation"`
|
||||
Version string `json:"version,omitempty" bun:",nullzero"`
|
||||
}
|
||||
41
internal/trans/model/type.go
Normal file
41
internal/trans/model/type.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
// TypeKey should be set on a TransEntry to indicate the type of entry it is.
|
||||
const TypeKey = "type"
|
||||
|
||||
// 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 Type = "account"
|
||||
TransBlock Type = "block"
|
||||
TransDomainBlock Type = "domainBlock"
|
||||
TransEmailDomainBlock Type = "emailDomainBlock"
|
||||
TransFollow Type = "follow"
|
||||
TransFollowRequest Type = "followRequest"
|
||||
TransInstance Type = "instance"
|
||||
TransUser Type = "user"
|
||||
)
|
||||
|
||||
// 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{}
|
||||
50
internal/trans/model/user.go
Normal file
50
internal/trans/model/user.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package trans
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// User represents a local instance user as serialized to an export file.
|
||||
type User struct {
|
||||
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" 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"`
|
||||
ChosenLanguages []string `json:"chosenLanguages,omitempty" bun:",nullzero"`
|
||||
FilteredLanguages []string `json:"filteredLanguage,omitempty" bun:",nullzero"`
|
||||
Locale string `json:"locale" bun:",nullzero"`
|
||||
LastEmailedAt time.Time `json:"lastEmailedAt,omitempty" bun:",nullzero"`
|
||||
ConfirmationToken string `json:"confirmationToken,omitempty" bun:",nullzero"`
|
||||
ConfirmationSentAt *time.Time `json:"confirmationTokenSentAt,omitempty" bun:",nullzero"`
|
||||
ConfirmedAt *time.Time `json:"confirmedAt,omitempty" bun:",nullzero"`
|
||||
UnconfirmedEmail string `json:"unconfirmedEmail,omitempty" bun:",nullzero"`
|
||||
Moderator bool `json:"moderator"`
|
||||
Admin bool `json:"admin"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Approved bool `json:"approved"`
|
||||
ResetPasswordToken string `json:"resetPasswordToken,omitempty" bun:",nullzero"`
|
||||
ResetPasswordSentAt *time.Time `json:"resetPasswordSentAt,omitempty" bun:",nullzero"`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue