models

package
v0.0.0-...-31b0ff0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFromTables

func DeleteFromTables(db *gorm.DB)

DeleteFromTables removes all contents in the database!

func Migrate

func Migrate(db *gorm.DB)

Migrate does gorm automatic migrations.

func ModelSetup

func ModelSetup(db *gorm.DB)

ModelSetup creates join tables etc.

Types

type Actor

type Actor struct {
	abstract.Object
	Username     string   `json:"preferredUsername"`
	Domain       string   `json:"-"`
	Name         string   `json:"name"`
	Summary      string   `json:"summary"`
	PublicKey    string   `json:"-"`
	FollowersURI string   `json:"followers"`
	FollowingURI string   `json:"following"`
	InboxURI     string   `json:"inbox"`
	OutboxURI    string   `json:"outbox"`
	CreatedPosts []Post   `gorm:"foreignKey:AuthorID"`
	Followers    []*Actor `gorm:"many2many:Follow;joinForeignKey:FollowingID;joinReferences:FollowingID"`
	Following    []*Actor `gorm:"many2many:Follow;joinForeignKey:FollowerID;joinReferences:FollowerID"`
	User         *User
	Categories   []Category `gorm:"foreignKey:CommuneID"`
}

Actor is an abstract user either person, bot or a group of people. Don't create table for it.

func (*Actor) GetDomain

func (actor *Actor) GetDomain() string

func (*Actor) GetFollowersURI

func (actor *Actor) GetFollowersURI() string

func (*Actor) GetFollowingURI

func (actor *Actor) GetFollowingURI() string

func (*Actor) GetInboxURI

func (actor *Actor) GetInboxURI() string

func (*Actor) GetOutboxURI

func (actor *Actor) GetOutboxURI() string

func (*Actor) GetPublicKey

func (actor *Actor) GetPublicKey() string

func (*Actor) GetPublicKeyURI

func (actor *Actor) GetPublicKeyURI() string

func (*Actor) GetURI

func (actor *Actor) GetURI() string

func (*Actor) GetURL

func (actor *Actor) GetURL() string

func (*Actor) GetUsername

func (actor *Actor) GetUsername() string

func (*Actor) IsBot

func (actor *Actor) IsBot() bool

func (*Actor) IsCommune

func (actor *Actor) IsCommune() bool

func (*Actor) IsLocal

func (actor *Actor) IsLocal(localDomains []string) bool

func (*Actor) RestChildren

func (actor *Actor) RestChildren() map[string]interface{}

type Category

type Category struct {
	abstract.Object
	CommuneID int
	Commune   *Actor
	Slug      string
	Posts     []*Post
}

Category contains many Posts.

func (*Category) GetDomain

func (category *Category) GetDomain() string

func (*Category) GetURI

func (category *Category) GetURI() string

func (*Category) GetURL

func (category *Category) GetURL() string

type Follow

type Follow struct {
	FollowerID  int   `gorm:"primaryKey;"`
	Follower    Actor `gorm:"foreignKey:FollowerID;references:ID;"`
	FollowingID int   `gorm:"primaryKey;"`
	Following   Actor `gorm:"foreignKey:FollowingID;references:ID;"`
	CreatedAt   time.Time
	Role        string
}

type Post

type Post struct {
	abstract.Object
	AuthorID        int
	Author          Actor
	CategoryID      *int
	Category        *Category
	Content         string
	MediaType       string
	Source          string
	SourceMediaType string
	Name            string
	ReplyToID       *int
	ReplyTo         *Post
	BoostToID       *int
	BoostTo         *Post
}

Post is a general posting.

func (*Post) GetActivityCreate

func (post *Post) GetActivityCreate() interfaces.IObject

func (*Post) GetAuthorURI

func (post *Post) GetAuthorURI() string

func (*Post) GetContent

func (post *Post) GetContent() string

func (*Post) GetDomain

func (post *Post) GetDomain() string

func (*Post) GetInReplyTo

func (post *Post) GetInReplyTo() string

func (*Post) GetName

func (post *Post) GetName() string

func (*Post) GetSource

func (post *Post) GetSource() string

func (*Post) GetSourceMediaType

func (post *Post) GetSourceMediaType() string

func (*Post) GetURI

func (post *Post) GetURI() string

func (*Post) GetURL

func (post *Post) GetURL() string

type User

type User struct {
	ActorID           int     `gorm:"primaryKey;autoIncrement:false;"`
	Actor             Actor   `gorm:"foreignKey:ActorID"`
	Email             *string `gorm:"unique"`
	EncryptedPassword string
	PrivateKey        string
	IsVerified        bool
	IsAdmin           bool
	IsModerator       bool
}

User is the private part of a local account.

func NewLocalCommune

func NewLocalCommune(username string, domain string, autoVerify bool) *User

NewLocalCommune creates a new User struct without insert it into database.

func NewUser

func NewUser(username string, domain string, email string, password string) *User

NewUser creates a new User struct without insert it into database.

func (*User) Authenticate

func (user *User) Authenticate(password string) error

Authenticate uses bcrypt for now.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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