start work on accounts module

This commit is contained in:
tsmethurst
2021-03-23 13:17:54 +01:00
parent aa9ce272dc
commit 7139116e5d
7 changed files with 133 additions and 6 deletions

View File

@ -24,6 +24,8 @@ package gtsmodel
import (
"net/url"
"time"
"github.com/gotosocial/gotosocial/pkg/mastotypes"
)
// Account represents either a local or a remote fediverse account, gotosocial or otherwise (mastodon, pleroma, etc)
@ -63,6 +65,8 @@ type Account struct {
UpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
// When should this account function until
SubscriptionExpiresAt time.Time `pg:"type:timestamp"`
// Does this account identify itself as a bot?
Bot bool
/*
PRIVACY SETTINGS
@ -153,3 +157,22 @@ type Header struct {
HeaderRemoteURL *url.URL `pg:"type:text"`
HeaderStorageSchemaVersion int
}
// ToMastoSensitive returns this account as a mastodon api type, ready for serialization
func (a *Account) ToMastoSensitive() *mastotypes.Account {
return &mastotypes.Account{
ID: a.ID,
Username: a.Username,
Acct: a.Username, // equivalent to username for local users only, which sensitive always is
DisplayName: a.DisplayName,
Locked: a.Locked,
Bot: a.Bot,
CreatedAt: a.CreatedAt.Format(time.RFC3339),
Note: a.Note,
URL: a.URL,
Avatar: a.Avatar.AvatarRemoteURL.String(),
AvatarStatic: a.AvatarRemoteURL.String(),
Header: a.Header.HeaderRemoteURL.String(),
HeaderStatic: a.Header.HeaderRemoteURL.String(),
}
}

View File

@ -41,8 +41,8 @@ type Application struct {
VapidKey string
}
// ToMastotype returns this application as a mastodon api type, ready for serialization
func (a *Application) ToMastotype() *mastotypes.Application {
// ToMasto returns this application as a mastodon api type, ready for serialization
func (a *Application) ToMasto() *mastotypes.Application {
return &mastotypes.Application{
ID: a.ID,
Name: a.Name,

View File

@ -0,0 +1,38 @@
/*
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 gtsmodel
import "time"
type Follow struct {
// id of this follow in the database
ID string `pg:"type:uuid,default:gen_random_uuid(),pk,notnull,unique"`
// When was this follow created?
CreatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
// When was this follow last updated?
UpdatedAt time.Time `pg:"type:timestamp,notnull,default:now()"`
// Who does this follow belong to?
AccountID string `pg:",unique:srctarget,notnull"`
// Who does AccountID follow?
TargetAccountID string `pg:",unique:srctarget,notnull"`
// Does this follow also want to see reblogs and not just posts?
ShowReblogs bool `pg:"default:true"`
// What is the activitypub URI of this follow?
URI string `pg:",unique"`
}