models

package
v0.0.0-...-eb23ef5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID                  int64                 `validate:"-" bun:"id,pk,autoincrement"`
	CreatedAt           time.Time             `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt           time.Time             `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	ActorURI            string                `validate:"url" bun:",nullzero,notnull"`
	Username            string                `validate:"-" bun:",unique:unique_fedi_user,nullzero,notnull"`
	InstanceID          int64                 `validate:"-" bun:",unique:unique_fedi_user,nullzero,notnull"`
	Instance            *Instance             `validate:"-" bun:"rel:belongs-to,join:instance_id=id"`
	DisplayName         string                `validate:"-" bun:",nullzero"`
	LastFinger          time.Time             `validate:"-" bun:",notnull"`
	LogInCount          int64                 `validate:"-" bun:",notnull"`
	LogInLast           time.Time             `validate:"-" bun:",nullzero"`
	Groups              []*GroupMembership    `validate:"-" bun:"rel:has-many,join:id=account_id"`
	InstanceMemberships []*InstanceTeamMember `validate:"-" bun:"rel:has-many,join:id=account_id"`
}

Account represents a federated social account.

func (*Account) GetActorURI

func (a *Account) GetActorURI() (actorURI string)

GetActorURI returns the account's actor uri.

func (*Account) GetDisplayName

func (a *Account) GetDisplayName() (displayName string)

GetDisplayName returns the account's display name.

func (*Account) GetID

func (a *Account) GetID() (accountID int64)

GetID returns the account's database id.

func (*Account) GetInstance

func (a *Account) GetInstance() (instance fedihelper.Instance)

GetInstance returns the instance of the account.

func (*Account) GetLastFinger

func (a *Account) GetLastFinger() (lastFinger time.Time)

GetLastFinger returns the time of the last finger.

func (*Account) GetUsername

func (a *Account) GetUsername() (username string)

GetUsername returns the account's username.

func (*Account) InGroup

func (a *Account) InGroup(groups ...Group) bool

func (*Account) SetActorURI

func (a *Account) SetActorURI(actorURI string)

SetActorURI sets the account's actor uri.

func (*Account) SetDisplayName

func (a *Account) SetDisplayName(displayName string)

SetDisplayName sets the account's display name.

func (*Account) SetInstance

func (a *Account) SetInstance(instanceI fedihelper.Instance)

SetInstance sets the instance of the account.

func (*Account) SetLastFinger

func (a *Account) SetLastFinger(lastFinger time.Time)

SetLastFinger sets the time of the last finger.

func (*Account) SetUsername

func (a *Account) SetUsername(username string)

SetUsername sets the account's username.

func (*Account) String

func (a *Account) String() string

type Group

type Group int64
const (
	GroupUnknown Group = iota
	GroupAdmin
	GroupMod
	GroupCDNUser
)

func GroupName

func GroupName(g string) Group

GroupName return a uuid for the group name

func (Group) String

func (g Group) String() string

type GroupMembership

type GroupMembership struct {
	ID        int64     `validate:"-" bun:"id,pk,autoincrement"`
	CreatedAt time.Time `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	AccountID int64     `validate:"min=1" bun:",unique:group_membership,notnull,nullzero"`
	Account   *Account  `validate:"-" bun:"rel:belongs-to,join:account_id=id"`
	Group     Group     `validate:"min=1" bun:",unique:group_membership,notnull,nullzero"`
}

GroupMembership represents a user's membership in a group

type Instance

type Instance struct {
	ID                int64          `validate:"-" bun:",pk,autoincrement,nullzero,notnull,unique"`
	CreatedAt         time.Time      `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt         time.Time      `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	Domain            string         `validate:"required,fqdn" bun:",nullzero,notnull,unique"`
	ServerHostname    string         `validate:"required,fqdn" bun:",nullzero,notnull,unique"`
	Software          string         `validate:"-" bun:",nullzero"`
	PublicKey         *rsa.PublicKey `validate:"-"`
	PrivateKey        string         `validate:"-" bun:",nullzero"`
	ActorIRI          string         `validate:"required,url" bun:",nullzero,notnull,unique"`
	InboxIRI          string         `validate:"required,url" bun:",nullzero,notnull,unique"`
	OAuthClientID     string         `validate:"-" bun:",nullzero"`
	OAuthClientSecret string         `validate:"-" bun:",nullzero"`
	Team              InstanceTeam   `validate:"-" bun:"rel:has-many,join:id=instance_id"`
	S3IsEnabled       bool           `validate:"-" bun:",notnull"`
	S3AccessKey       string         `validate:"-" bun:",nullzero"`
	S3SecretAccessKey string         `validate:"-" bun:",nullzero"`
	S3KeyCreationDate time.Time      `validate:"-" bun:",nullzero"`
}

Instance represents a federated social instance

func (*Instance) GetActorURI

func (i *Instance) GetActorURI() (actorURI string)

func (*Instance) GetDomain

func (i *Instance) GetDomain() (domain string)

func (*Instance) GetID

func (i *Instance) GetID() (instanceID int64)

func (*Instance) GetOAuthClientID

func (i *Instance) GetOAuthClientID() (clientID string)

func (*Instance) GetOAuthClientSecret

func (i *Instance) GetOAuthClientSecret() (string, error)

GetOAuthClientSecret returns unencrypted client secret.

func (*Instance) GetPrivateKey

func (i *Instance) GetPrivateKey() (*rsa.PrivateKey, error)

GetPrivateKey returns unencrypted client secret.

func (*Instance) GetS3SecretAccessKey

func (i *Instance) GetS3SecretAccessKey() (string, error)

GetS3SecretAccessKey returns unencrypted client secret.

func (*Instance) GetServerHostname

func (i *Instance) GetServerHostname() (hostname string)

func (*Instance) GetSoftware

func (i *Instance) GetSoftware() (software string)

func (*Instance) IsPunycode

func (i *Instance) IsPunycode() bool

IsPunycode returns true if the domain is a punycode domain.

func (*Instance) PublicKeyPEM

func (i *Instance) PublicKeyPEM() (string, error)

PublicKeyPEM returns a PEM string from the public key.

func (*Instance) SetActorURI

func (i *Instance) SetActorURI(actorURI string)

func (*Instance) SetDomain

func (i *Instance) SetDomain(domain string)

func (*Instance) SetInboxURI

func (i *Instance) SetInboxURI(inboxURI string)

func (*Instance) SetOAuthClientID

func (i *Instance) SetOAuthClientID(clientID string)

func (*Instance) SetOAuthClientSecret

func (i *Instance) SetOAuthClientSecret(clientSecret string) error

SetOAuthClientSecret sets encrypted client secret.

func (*Instance) SetPrivateKey

func (i *Instance) SetPrivateKey(key *rsa.PrivateKey) error

SetPrivateKey sets encrypted client secret.

func (*Instance) SetS3SecretAccessKey

func (i *Instance) SetS3SecretAccessKey(clientSecret string) error

SetS3SecretAccessKey sets encrypted client secret.

func (*Instance) SetServerHostname

func (i *Instance) SetServerHostname(hostname string)

func (*Instance) SetSoftware

func (i *Instance) SetSoftware(software string)

func (*Instance) UnicodeDomain

func (i *Instance) UnicodeDomain() string

UnicodeDomain returns a unicode representation of the domain.

type InstanceTeam

type InstanceTeam []*InstanceTeamMember

func (InstanceTeam) GetMember

func (t InstanceTeam) GetMember(id int64) (*InstanceTeamMember, bool)

func (InstanceTeam) GetOwner

func (t InstanceTeam) GetOwner() (*InstanceTeamMember, bool)

type InstanceTeamMember

type InstanceTeamMember struct {
	ID         int64     `validate:"-" bun:"id,pk,autoincrement"`
	CreatedAt  time.Time `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt  time.Time `validate:"-" bun:",nullzero,notnull,default:current_timestamp"`
	InstanceID int64     `validate:"min=1" bun:",unique:instance_team_membership,notnull,nullzero"`
	Instance   *Instance `validate:"-" bun:"rel:belongs-to,join:instance_id=id"`
	AccountID  int64     `validate:"min=1" bun:",unique:instance_team_membership,notnull,nullzero"`
	Account    *Account  `validate:"-" bun:"rel:belongs-to,join:account_id=id"`
	IsOwner    bool      `validate:"-" bun:",notnull"`
}

InstanceTeamMember represents a membership in an instance's team

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL