models

package
v0.0.0-...-4c68550 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNoPreferredUsername = errors.New("remote activitypub entity does not have a preferred username set, rejecting")
	ErrorNoPublicKey         = errors.New("remote activitypub entity does not have a public key set, rejecting")
)
View Source
var ErrActorFollowNotFound = errors.New("actor follow not found")
View Source
var ErrActorNotFound = errors.New("actor not found")
View Source
var ErrInstanceNotFound = errors.New("reading unknown instance from store")

Functions

func BuildActivityApplication

func BuildActivityApplication(actor *Actor, config *instance.FederationConfig) vocab.ActivityStreamsApplication

func CreateCreateActivity

func CreateCreateActivity(id string, instanceIri *url.URL, localActorIRI *url.URL) vocab.ActivityStreamsCreate

func GetFullUsernameFromExternalEntity

func GetFullUsernameFromExternalEntity(entity ExternalEntity) string

func MakeActivityDirect

func MakeActivityDirect(activity vocab.ActivityStreamsCreate, toIRI *url.URL) vocab.ActivityStreamsCreate

MakeActivityDirect sets the required properties to make this activity seen as a direct message.

func MakeActivityPublic

func MakeActivityPublic(activity vocab.ActivityStreamsCreate, isPrivate bool) vocab.ActivityStreamsCreate

MakeActivityPublic sets the required properties to make this activity seen as public.

func MakeCreateActivity

func MakeCreateActivity(activityID *url.URL) vocab.ActivityStreamsCreate

MakeCreateActivity will return a new Create activity with the provided ID.

func MakeNote

func MakeNote(text string, noteIRI *url.URL, attributedToIRI *url.URL) vocab.ActivityStreamsNote

MakeNote will return a new Note object.

func MakeNoteDirect

func MakeNoteDirect(note vocab.ActivityStreamsNote, toIRI *url.URL) vocab.ActivityStreamsNote

MakeNoteDirect sets the required properties to make this note seen as a direct message.

func MakeNotePublic

MakeNotePublic ses the required proeprties to make this note seen as public.

func MakeUpdateActivity

func MakeUpdateActivity(activityID *url.URL, isPrivate bool) vocab.ActivityStreamsUpdate

MakeUpdateActivity will return a new Update activity with the provided aID.

func Serialize

func Serialize(obj vocab.Type) ([]byte, error)

Types

type Actor

type Actor struct {
	ActorType         string         `gorm:""`
	PublicKey         string         `gorm:""`
	PrivateKey        sql.NullString `gorm:""`
	ActorIri          string         `gorm:"index;unique;"`
	FollowingIri      string         `gorm:""`
	FollowersIri      string         `gorm:""`
	InboxIri          string         `gorm:""`
	OutboxIri         string         `gorm:""`
	SharedInboxIri    string         `gorm:""`
	DisabledAt        sql.NullTime   `gorm:""`
	ServerId          sql.NullInt64  `gorm:""`
	RemoteCreatedAt   time.Time      `gorm:""`
	PreferredUsername string         `gorm:""`
	Follower          []*Follow      `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Following         []*Follow      `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	VideoGuest        []*Video       `gorm:"many2many:video_guests;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	gorm.Model
}

func MakeActorFromExernalAPEntity

func MakeActorFromExernalAPEntity(entity ExternalEntity) (*Actor, error)

MakeActorFromExernalAPEntity takes a full ActivityPub entity and returns our internal representation of an actor.

func NewInstanceActor

func NewInstanceActor(instanceUrl *url.URL, name string) (*Actor, error)

func NewTrustedInstanceActor

func NewTrustedInstanceActor(actorIri *url.URL, name string) (*Actor, error)

func (*Actor) GetActorIri

func (s *Actor) GetActorIri() *url.URL

func (*Actor) GetActorType

func (s *Actor) GetActorType() ActorType

func (*Actor) GetInboxIri

func (s *Actor) GetInboxIri() *url.URL

func (*Actor) GetOutboxIri

func (s *Actor) GetOutboxIri() *url.URL

func (*Actor) GetSharedInboxIri

func (s *Actor) GetSharedInboxIri() *url.URL

type ActorRepository

type ActorRepository struct {
	// contains filtered or unexported fields
}

func NewActorRepository

func NewActorRepository(config *instance.FederationConfig, storage storage.Storage) *ActorRepository

func (*ActorRepository) Add

func (r *ActorRepository) Add(_ context.Context, actor *Actor) (*Actor, error)

func (*ActorRepository) GetActorByActorIRI

func (r *ActorRepository) GetActorByActorIRI(ctx context.Context, actorIri *url.URL) (*Actor, error)

func (*ActorRepository) GetActorForIRI

func (r *ActorRepository) GetActorForIRI(ctx context.Context, iri *url.URL, iriType IriType) (*Actor, error)

GetActorForIRI @deprecated

func (*ActorRepository) GetActorForUserName

func (r *ActorRepository) GetActorForUserName(ctx context.Context, name string) (*Actor, error)

func (*ActorRepository) GetAllActorsByIds

func (r *ActorRepository) GetAllActorsByIds(ctx context.Context, actorIds []uint) ([]*Actor, error)

func (*ActorRepository) GetKeyPair

func (r *ActorRepository) GetKeyPair(ctx context.Context, actorIRI *url.URL) (publicKey string, privateKey string, err error)

func (*ActorRepository) GetPrivateKey

func (r *ActorRepository) GetPrivateKey(ctx context.Context, actorIRI *url.URL) (string, error)

func (*ActorRepository) GetPublicKey

func (r *ActorRepository) GetPublicKey(ctx context.Context, actorIRI *url.URL) (string, error)

func (*ActorRepository) Upsert

func (r *ActorRepository) Upsert(ctx context.Context, actor *Actor) (*Actor, error)

type ActorType

type ActorType uint
const (
	Person ActorType = iota
	Group
	Organization
	Application
	Service
	Bot
)

func ActorTypeFromString

func ActorTypeFromString(str string) ActorType

func (ActorType) String

func (at ActorType) String() string

type ExternalEntity

type ExternalEntity interface {
	GetJSONLDId() vocab.JSONLDIdProperty
	GetActivityStreamsInbox() vocab.ActivityStreamsInboxProperty
	GetActivityStreamsName() vocab.ActivityStreamsNameProperty
	GetActivityStreamsPreferredUsername() vocab.ActivityStreamsPreferredUsernameProperty
	GetActivityStreamsIcon() vocab.ActivityStreamsIconProperty
	GetW3IDSecurityV1PublicKey() vocab.W3IDSecurityV1PublicKeyProperty
}

type Follow

type Follow struct {
	Iri           string `gorm:"iri;not null;index;"`
	ActorId       uint   `gorm:"actor_id;not null;"`
	TargetActorId uint   `gorm:"target_actor_id;not null;"`
	State         string `gorm:"state;not null;"`
	Actor         *Actor `gorm:"foreignKey:ActorId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	TargetActor   *Actor `gorm:"foreignKey:TargetActorId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`

	gorm.Model
	// contains filtered or unexported fields
}

func NewFollow

func NewFollow(actor *Actor, target *Actor, config *instance.FederationConfig) *Follow

func (*Follow) GetIri

func (f *Follow) GetIri() *url.URL

func (*Follow) ToAS

func (f *Follow) ToAS() (vocab.ActivityStreamsFollow, error)

type FollowRepository

type FollowRepository struct {
	// contains filtered or unexported fields
}

func NewFollowRepository

func NewFollowRepository(config *instance.FederationConfig, storage storage.Storage) *FollowRepository

func (*FollowRepository) Add

func (r *FollowRepository) Add(ctx context.Context, follow *Follow) (*Follow, error)

func (*FollowRepository) GetActorFollowers

func (r *FollowRepository) GetActorFollowers(ctx context.Context, actorId uint) ([]*Follow, error)

func (*FollowRepository) GetActorFollowsFromActorId

func (r *FollowRepository) GetActorFollowsFromActorId(ctx context.Context, actorId uint) ([]*Follow, error)

func (*FollowRepository) GetFollowByIri

func (r *FollowRepository) GetFollowByIri(ctx context.Context, iri string) (*Follow, error)

func (*FollowRepository) Update

func (r *FollowRepository) Update(ctx context.Context, follow *Follow) (*Follow, error)

func (*FollowRepository) UpdateFollower

func (r *FollowRepository) UpdateFollower(ctx context.Context, falower *Follow) error

type FollowState

type FollowState uint
const (
	Accepted FollowState = iota
	Pending
	Rejected
)

func (FollowState) String

func (fs FollowState) String() string

type Instance

type Instance struct {
	ActorId uint   `gorm:"not null;unique;"`
	Actor   *Actor `gorm:"foreignKey:ActorId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	gorm.Model
}

func NewInstance

func NewInstance(actor *Actor) *Instance

type InstanceRepository

type InstanceRepository struct {
	// contains filtered or unexported fields
}

func NewInstanceRepository

func NewInstanceRepository(config *instance.FederationConfig, storage storage.Storage) *InstanceRepository

func (*InstanceRepository) GetInstanceByActorIri

func (r *InstanceRepository) GetInstanceByActorIri(ctx context.Context, actorIri *url.URL) (*Instance, error)

func (*InstanceRepository) Upsert

func (r *InstanceRepository) Upsert(ctx context.Context, instance *Instance) (*Instance, error)

type IriType

type IriType int64
const (
	InboxIri IriType = iota
	ActorIri
)

type LiveVideoLatencyMode

type LiveVideoLatencyMode uint
const (
	DEFAULT LiveVideoLatencyMode = iota
	HIGH_LATENCY
	SMALL_LATENCY
)

type PrivacyAudience

type PrivacyAudience = string
const (
	// PUBLIC is an audience meaning anybody can view the item.
	PUBLIC PrivacyAudience = "https://www.w3.org/ns/activitystreams#Public"
)

type Video

type Video struct {
	Iri             string       `gorm:"not null;index;unique;"`
	Uuid            string       `gorm:"not null;index;unique;"`
	Name            string       `gorm:""`
	ShigActive      bool         `gorm:"not null;default:false;"`
	InstanceId      uint         `gorm:"not null;"`
	Instance        *Instance    `gorm:"foreignKey:InstanceId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	OwnerId         uint         `gorm:"not null;"`
	Owner           *Actor       `gorm:"foreignKey:OwnerId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	ChannelId       uint         `gorm:"not null;"`
	Channel         *Actor       `gorm:"foreignKey:ChannelId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Guests          []*Actor     `gorm:"many2many:video_guests;"`
	IsLiveBroadcast bool         `gorm:"not null;default:false;"`
	LiveSaveReplay  bool         `gorm:"not null;default:false;"`
	PermanentLive   bool         `gorm:""`
	LatencyMode     uint         `gorm:"not null;default:1;"`
	Published       sql.NullTime `gorm:""`
	State           uint         `gorm:"not null;default:0"`

	gorm.Model
	// contains filtered or unexported fields
}

func (*Video) GetLatencyMode

func (s *Video) GetLatencyMode() LiveVideoLatencyMode

func (*Video) GetState

func (s *Video) GetState() VideoState

func (*Video) GetVideoIri

func (s *Video) GetVideoIri() *url.URL

type VideoRepository

type VideoRepository struct {
	// contains filtered or unexported fields
}

func NewVideoRepository

func NewVideoRepository(config *instance.FederationConfig, storage storage.Storage) *VideoRepository

func (*VideoRepository) DeleteByIri

func (r *VideoRepository) DeleteByIri(ctx context.Context, iri string) error

func (*VideoRepository) Upsert

func (r *VideoRepository) Upsert(ctx context.Context, video *Video) (*Video, error)

type VideoState

type VideoState uint
const (
	PUBLISHED VideoState = iota
	TO_TRANSCODE
	TO_IMPORT
	WAITING_FOR_LIVE
	LIVE_ENDED
	TO_MOVE_TO_EXTERNAL_STORAGE
	TRANSCODING_FAILED
	TO_MOVE_TO_EXTERNAL_STORAGE_FAILED
	TO_EDIT
)

Jump to

Keyboard shortcuts

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