models

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TestChannelID1 - uuid of channel 1 for testing
	TestChannelID1 = uuid.MustParse("df1555f5-7046-4f7a-adcc-195b73949723")

	// TestChannelID2 - uuid of channel 2 for testing
	TestChannelID2 = uuid.MustParse("c4eba06b-1ab3-4367-93e1-da584b96fcc8")
)
View Source
var (

	// TestEventID1 - uuid of event 1 for testing
	TestEventID1 = uuid.MustParse("bff61adc-76d5-4beb-aab0-3ef11b337204")

	// TestEventID2 - uuid of event 2 for testing
	TestEventID2 = uuid.MustParse("4abb3a05-60a3-4be5-a6aa-323b9755e0b5")
)
View Source
var (
	TestRecording1ID        = uuid.MustParse("542685cb-3693-e720-a957-f008f5dae3ee")
	TestRecording1IDLang1   = uuid.MustParse("03d33e6a-151f-47d9-be79-a726e0f9a859")
	TestRecording1IDFormat1 = uuid.MustParse("3a4f9157-65bf-4d15-a82b-1cd9295d07e0")
)
View Source
var (
	TestStreamID1         = uuid.MustParse("728edaf7-9ad9-f972-4d09-ba5940cd43f9")
	TestStream1IDLang1    = uuid.MustParse("acdf7eb1-0cb9-4900-a918-a411f9afc38d")
	TestStream1IDSpeaker1 = uuid.MustParse("0030a199-c771-489a-88a7-258f80db2bce")
)

uuid of streams for testing

View Source
var (
	// TestTagBuchvorstellungID - uuid for tag buchvorstellung
	TestTagBuchvorstellungID = uuid.MustParse("0bca0cf4-a9b9-46d7-821f-18c59c08fc1d")

	// TestTagDiskussionID - uuid for tag diskussion
	TestTagDiskussionID = uuid.MustParse("277026b0-b9d6-48d6-bfa1-96dcc7eb3451")

	// TestTagVortragID - uuid for tag vortrag
	TestTagVortragID = uuid.MustParse("7297a654-71f9-43be-8120-69b8152f01fc")

	// TestTagKonzertID - uuid for tag konzert
	TestTagKonzertID = uuid.MustParse("71082693-c58d-43b7-86ff-6b240c643a83")

	// TestTagAusstellungID - uuid for tag galerie
	TestTagAusstellungID = uuid.MustParse("87fb7f4b-1e5c-4c1b-8020-2860987da6bc")

	// TestTagInterviewID - uuid for tag interview
	TestTagInterviewID = uuid.MustParse("1aa3f441-4461-42da-a858-63abf5ee254c")
)
View Source
var (
	// TestUserID1 - uuid of initial user
	TestUserID1 = uuid.MustParse("88078ec0-2135-445f-bf05-632701c77695")
	TestUserID2 = uuid.MustParse("aca3f761-042b-4c7f-a8d1-82e972683adf")
)
View Source
var (
	TestRecording19ID = uuid.MustParse("bd2cb25e-6f17-453d-b947-370cd51beb18")
)

Test Recording for privat

View Source
var (
	TestStreamID2 = uuid.MustParse("0801a547-59f1-4a63-946f-2ab03f62e6ee")
)

Testdata ID

Functions

func SetupMigration added in v0.1.1

func SetupMigration(db *database.Database)

SetupMigration - setup all data for migration

Types

type Channel

type Channel struct {
	ID uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"df1555f5-7046-4f7a-adcc-195b73949723"`
	// attributes
	CommonName string       `json:"common_name" gorm:"unique" example:"kukoon"`
	Title      string       `json:"title" example:"Im Kukoon"`
	Recordings []*Recording `json:"recordings,omitempty" gorm:"constraint:OnDelete:CASCADE" swaggerignore:"true"`
	Owners     []User       `json:"-" gorm:"many2many:user_channels;constraint:OnDelete:CASCADE"`
}

Channel struct

func (Channel) HasPermission added in v0.1.1

func (Channel) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on channel

type Event

type Event struct {
	ID          uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"5f410ec2-8eb8-4afd-b1f1-5a76114cc53e"`
	OwnerID     uuid.UUID `json:"-" gorm:"type:uuid"` // channel
	Owner       Channel   `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Name        string    `json:"name"`
	URL         string    `json:"url,omitempty"`
	Description string    `json:"description,omitempty"`
}

Event struct

func (Event) HasPermission added in v0.2.0

func (Event) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on event

type PublicStream

type PublicStream struct {
	ID        uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"dffe2c0e-3713-4399-8ee2-279becbbb06e"`
	Channel   Channel   `json:"channel" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ChannelID uuid.UUID `json:"-" gorm:"type:uuid;unique_index:idx_stream_channel"`
	Secret    string    `json:"-"`
	ListenAt  time.Time `json:"-"`
	StartAt   time.Time `json:"start_at" example:"2020-12-10T19:00:00.000000+01:00"`
	EndAt     time.Time `json:"end_at" example:"2020-12-10T22:00:00.000000+01:00"`
	Chat      bool      `json:"chat"`
	Running   bool      `json:"running"`
	// attributes
	Poster   string      `` /* 147-byte string literal not displayed */
	Preview  string      `` /* 149-byte string literal not displayed */
	Lang     *StreamLang `json:"lang" gorm:"foreignkey:StreamID"`
	EventID  *uuid.UUID  `json:"-" gorm:"type:uuid"`
	Event    *Event      `json:"event,omitempty"`
	Tags     []*Tag      `json:"tags,omitempty" gorm:"many2many:stream_tags"`
	Speakers []*Speaker  `json:"speakers,omitempty" gorm:"many2many:stream_speakers"`
}

PublicStream struct without secrets TODO maybe better in api model

func (PublicStream) TableName

func (PublicStream) TableName() string

TableName of public stream struct (to fetch from same table then stream)

type Recording

type Recording struct {
	ID        uuid.UUID          `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"dffe2c0e-3713-4399-8ee2-279becbbb06e"`
	CreatedAt time.Time          `json:"created_at" example:"2020-12-10T19:00:00.000000+01:00"`
	UpdatedAt time.Time          `json:"updated_at" example:"2020-12-10T22:00:00.000000+01:00"`
	Channel   Channel            `json:"channel" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ChannelID uuid.UUID          `json:"-" gorm:"type:uuid;unique_index:idx_recording_channel"`
	Formats   []*RecordingFormat `json:"formats,omitempty" gorm:"constraint:OnDelete:CASCADE" swaggerignore:"true"`
	// attributes
	CommonName string           `json:"common_name" gorm:"unique_index:idx_recording_channel" example:"2020-12-polizeigewalt"`
	Poster     string           `` /* 139-byte string literal not displayed */
	Preview    string           `` /* 142-byte string literal not displayed */
	Duration   time.Duration    `json:"duration" swaggertype:"primitive,integer"`
	Public     bool             `json:"public"`
	Listed     bool             `json:"listed"`
	Viewers    uint64           `json:"viewers"`
	Lang       *RecordingLang   `json:"lang" gorm:"constraint:OnDelete:CASCADE"`
	Langs      []*RecordingLang `json:"-" gorm:"constraint:OnDelete:CASCADE" swaggerignore:"true"`
	LangShorts []string         `json:"lang_shorts,omitempty" gorm:"-"`
	EventID    *uuid.UUID       `json:"-" gorm:"type:uuid"`
	Event      *Event           `json:"event"`
	Tags       []*Tag           `json:"tags" gorm:"many2many:recording_tags;constraint:OnDelete:CASCADE"`
	Speakers   []*Speaker       `json:"speakers" gorm:"many2many:recording_speakers;constraint:OnDelete:CASCADE"`
}

Recording struct

func (*Recording) AfterFind added in v0.2.2

func (r *Recording) AfterFind(tx *gorm.DB) (err error)

func (Recording) HasPermission added in v0.2.0

func (Recording) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on stream

type RecordingFormat

type RecordingFormat struct {
	ID          uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"3a4f9157-65bf-4d15-a82b-1cd9295d07e0"`
	Recording   Recording `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	RecordingID uuid.UUID `json:"-" gorm:"type:uuid"`
	// attributes
	Lang  string `json:"lang" gorm:"unique_index:idx_recording_lang" example:"de"`
	URL   string `` /* 140-byte string literal not displayed */
	Bytes int64  `json:"bytes"`
	//Quality    0: origin quality, 100: 4k, 140: 1440p, 150: 1080p, 160: 720p, 180: 480p. 200: 360p, 250: 240p, 300: 144p
	Quality    int64  `json:"quality" example:"0"`
	IsVideo    bool   `json:"is_video" example:"true"`
	Resolution string `json:"resolution" example:"1920x1080"`
}

RecordingFormat struct - for format

func (RecordingFormat) HasPermission added in v0.2.0

func (RecordingFormat) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on stream

type RecordingLang

type RecordingLang struct {
	ID          uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"3a4f9157-65bf-4d15-a82b-1cd9295d07e0"`
	Recording   Recording `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	RecordingID uuid.UUID `json:"-" gorm:"type:uuid;unique_index:idx_recording_lang"`
	// attributes
	Lang     string `json:"lang" gorm:"unique_index:idx_recording_lang" example:"de"`
	Title    string `json:"title" example:"Polizeigewalt – ein deutsches Problem"`
	Subtitle string `` /* 206-byte string literal not displayed */
	Short    string `` /* 189-byte string literal not displayed */
	Long     string `` /* 405-byte string literal not displayed */
}

RecordingLang struct - for i18n data of a

func (RecordingLang) HasPermission added in v0.2.0

func (RecordingLang) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on stream

type Speaker

type Speaker struct {
	ID           uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"b778369e-d44f-4d15-bf79-a9e8faec022d"`
	OwnerID      uuid.UUID `json:"-" gorm:"type:uuid"` // channel
	Owner        Channel   `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Name         string    `json:"name" example:"Dr. Jane Buoy"`
	Organisation string    `json:"organisation,omitempty" example:"Kukoon"`
}

Speaker struct

func (Speaker) HasPermission added in v0.2.0

func (Speaker) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on speaker

type Stream

type Stream struct {
	ID        uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"dffe2c0e-3713-4399-8ee2-279becbbb06e"`
	Channel   Channel   `json:"channel" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ChannelID uuid.UUID `json:"-" gorm:"type:uuid;unique_index:idx_stream_channel"`
	Secret    string    `json:"secret" example:"717897bf-198c-4f1b-bb4f-5a25cb197107"`
	ListenAt  time.Time `json:"listen_at" example:"2020-12-10T00:00:00.000000+01:00"`
	StartAt   time.Time `json:"start_at" example:"2020-12-10T19:00:00.000000+01:00"`
	EndAt     time.Time `json:"end_at" example:"2020-12-10T22:00:00.000000+01:00"`
	Chat      bool      `json:"chat"`
	Running   bool      `json:"running"`
	// attributes
	CommonName string      `json:"common_name" gorm:"unique_index:idx_stream_channel" example:"2020-12-polizeigewalt"`
	Poster     string      `` /* 139-byte string literal not displayed */
	Preview    string      `` /* 142-byte string literal not displayed */
	Lang       *StreamLang `json:"lang" gorm:"constraint:OnDelete:CASCADE"`
	EventID    *uuid.UUID  `json:"-" gorm:"type:uuid"`
	Event      *Event      `json:"event,omitempty"`
	Tags       []*Tag      `json:"tags,omitempty" gorm:"many2many:stream_tags;constraint:OnDelete:CASCADE"`
	Speakers   []*Speaker  `json:"speakers,omitempty" gorm:"many2many:stream_speakers;constraint:OnDelete:CASCADE"`
}

Stream struct

func (*Stream) GetPublic

func (s *Stream) GetPublic() *PublicStream

func (Stream) HasPermission added in v0.1.1

func (Stream) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on stream

func (Stream) TableName

func (Stream) TableName() string

TableName of stream struct

type StreamLang

type StreamLang struct {
	ID        uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"3a4f9157-65bf-4d15-a82b-1cd9295d07e0"`
	CreatedAt time.Time `json:"created_at" example:"2020-12-10T19:00:00.000000+01:00"`
	UpdatedAt time.Time `json:"updated_at" example:"2020-12-10T22:00:00.000000+01:00"`
	Stream    Stream    `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	StreamID  uuid.UUID `json:"-" gorm:"type:uuid;unique_index:idx_stream_lang"`
	// attributes
	Lang     string `json:"lang" gorm:"unique_index:idx_stream_lang" example:"de"`
	Title    string `json:"title" example:"Pushbacks, Internierung, Zugangshürden"`
	Subtitle string `json:"subtitle" example:"Zum Stand des europäischen Migrations- und Grenzregimes"`
	Short    string `` /* 213-byte string literal not displayed */
	Long     string `` /* 206-byte string literal not displayed */
}

StreamLang struct - for i18n data of a stream

func (StreamLang) HasPermission added in v0.1.1

func (StreamLang) HasPermission(tx *gorm.DB, userID, objID uuid.UUID) (interface{}, error)

HasPermission - has user permission on stream

type Tag

type Tag struct {
	ID   uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"df1555f5-7046-4f7a-adcc-195b73949723"`
	Lang *TagLang  `json:"lang"`
}

Tag struct

type TagLang

type TagLang struct {
	ID    uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"df1555f5-7046-4f7a-adcc-195b73949723"`
	Tag   Tag       `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	TagID uuid.UUID `json:"-" gorm:"type:uuid;unique_index:idx_tag_lang"`
	// attributes
	Lang string `json:"lang" gorm:"unique_index:idx_tag_lang" example:"de"`
	Name string `json:"name" example:"Buchvorstellung"`
}

TagLang struct

type User

type User struct {
	ID         uuid.UUID  `json:"id" gorm:"type:uuid;default:gen_random_uuid()" example:"88078ec0-2135-445f-bf05-632701c77695"`
	Username   string     `json:"username" gorm:"unique" example:"kukoon"`
	Password   string     `json:"-" example:"super secret password"`
	ForgetCode *uuid.UUID `json:"-" gorm:"forget_code;type:uuid"`
	Channels   []Channel  `json:"-" gorm:"many2many:user_channels;"`
}

User struct

Jump to

Keyboard shortcuts

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