summaryrefslogtreecommitdiff
path: root/internal/trans/model
diff options
context:
space:
mode:
Diffstat (limited to 'internal/trans/model')
-rw-r--r--internal/trans/model/account.go54
-rw-r--r--internal/trans/model/block.go31
-rw-r--r--internal/trans/model/domainblock.go34
-rw-r--r--internal/trans/model/follow.go31
-rw-r--r--internal/trans/model/followrequest.go31
-rw-r--r--internal/trans/model/instance.go43
-rw-r--r--internal/trans/model/type.go41
-rw-r--r--internal/trans/model/user.go50
8 files changed, 315 insertions, 0 deletions
diff --git a/internal/trans/model/account.go b/internal/trans/model/account.go
new file mode 100644
index 000000000..2350048d7
--- /dev/null
+++ b/internal/trans/model/account.go
@@ -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"`
+}
diff --git a/internal/trans/model/block.go b/internal/trans/model/block.go
new file mode 100644
index 000000000..313e6a7cd
--- /dev/null
+++ b/internal/trans/model/block.go
@@ -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"`
+}
diff --git a/internal/trans/model/domainblock.go b/internal/trans/model/domainblock.go
new file mode 100644
index 000000000..de2bcd00a
--- /dev/null
+++ b/internal/trans/model/domainblock.go
@@ -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"`
+}
diff --git a/internal/trans/model/follow.go b/internal/trans/model/follow.go
new file mode 100644
index 000000000..b94f2600d
--- /dev/null
+++ b/internal/trans/model/follow.go
@@ -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"`
+}
diff --git a/internal/trans/model/followrequest.go b/internal/trans/model/followrequest.go
new file mode 100644
index 000000000..844bcb7af
--- /dev/null
+++ b/internal/trans/model/followrequest.go
@@ -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"`
+}
diff --git a/internal/trans/model/instance.go b/internal/trans/model/instance.go
new file mode 100644
index 000000000..a75aa65bf
--- /dev/null
+++ b/internal/trans/model/instance.go
@@ -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"`
+}
diff --git a/internal/trans/model/type.go b/internal/trans/model/type.go
new file mode 100644
index 000000000..76f57c843
--- /dev/null
+++ b/internal/trans/model/type.go
@@ -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{}
diff --git a/internal/trans/model/user.go b/internal/trans/model/user.go
new file mode 100644
index 000000000..293b124a2
--- /dev/null
+++ b/internal/trans/model/user.go
@@ -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"`
+}