internal

package
v0.0.0-...-a0d1ad3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

* MIT License * * Copyright (c) 2022 The hvxahv Authors. *

Index

Constants

View Source
const (
	// ErrNotFound is returned when a channel is not found.
	ErrNotFound   = "CHANNEL_NOT_FOUND"
	ChannelsTable = "channels"
)
View Source
const (
	// AdministrateTable is the table name for the administrates table.
	AdministrateTable = "administrates"
)
View Source
const (
	BroadcastsTableName = "broadcasts"
)
View Source
const (
	SubscribesTable = "subscribes"
)

Variables

This section is empty.

Functions

func Run

func Run() error

Types

type Administrates

type Administrates struct {
	gorm.Model

	ChannelId uint `gorm:"primaryKey;channel_id"`

	// AdminId admin actor id.
	AdminId uint `gorm:"primaryKey;admin_id"`
	IsOwner bool `gorm:"type:boolean;is_owner"`
}

func NewAdministratesAdd

func NewAdministratesAdd(channelId, adminId uint) *Administrates

func NewAdministratesAddOwner

func NewAdministratesAddOwner(channelId, adminId uint) *Administrates

func NewAdministratesPermission

func NewAdministratesPermission(channelId, adminId uint) *Administrates

func (*Administrates) AddAdministrator

func (adm *Administrates) AddAdministrator(addedID uint) error

AddAdministrator adds an administrator to a channel. Only administrators can add administrators.

func (*Administrates) AddAdministratorOwner

func (adm *Administrates) AddAdministratorOwner() error

AddAdministratorOwner Add the channel owner to the Admin table.

func (*Administrates) DeleteAdministrators

func (adm *Administrates) DeleteAdministrators() error

DeleteAdministrators ...

func (*Administrates) ExitAdministrator

func (adm *Administrates) ExitAdministrator() error

func (*Administrates) GetAdministrators

func (adm *Administrates) GetAdministrators() ([]*Administrates, error)

GetAdministrators ... Returns all administrators of a channel. Check permissions. Only administrator can view the list of administrators who manage the channel.

func (*Administrates) IsAdministrator

func (adm *Administrates) IsAdministrator() bool

func (*Administrates) IsChannelOwner

func (adm *Administrates) IsChannelOwner() bool

func (*Administrates) RemoveAdministrator

func (adm *Administrates) RemoveAdministrator(removedId uint) error

type Administrator

type Administrator interface {
	IsAdministrator() bool
	IsChannelOwner() bool
	AddAdministratorOwner() error
	AddAdministrator(addedID uint) error
	RemoveAdministrator(removedId uint) error
	GetAdministrators() ([]*Administrates, error)
	ExitAdministrator() error
	DeleteAdministrators() error
}

type Broadcast

type Broadcast interface {
	Create() error
	GetBroadcasts() ([]*Broadcasts, error) // Get all broadcasts.
	Delete() error
}

type Broadcasts

type Broadcasts struct {
	gorm.Model

	ChannelId uint `gorm:"primaryKey;type:bigint;channel_id"`

	// ActorId in the AdminId Actor data table, which identifies the creator of the Broadcast.
	// Must be the administrator of the channel.
	AdminId uint   `gorm:"type:bigint;admin_id"`
	CID     string `gorm:"type:text;cid"`
}

func NewBroadcasts

func NewBroadcasts(channelId, adminId uint, cid string) *Broadcasts

func NewBroadcastsChannelId

func NewBroadcastsChannelId(channelId uint) *Broadcasts

func NewBroadcastsDelete

func NewBroadcastsDelete(id, channelId, adminId uint) *Broadcasts

func (*Broadcasts) Create

func (b *Broadcasts) Create() error

func (*Broadcasts) Delete

func (b *Broadcasts) Delete() error

func (*Broadcasts) GetBroadcasts

func (b *Broadcasts) GetBroadcasts() ([]*Broadcasts, error)

type Channel

type Channel interface {
	// CreateChannel is used to create a channel.
	CreateChannel() error

	// GetChannels is used to retrieve all channels for a creator.
	GetChannels() ([]*Channels, error)

	// DeleteChannel is used to delete a channel.
	DeleteChannel() error

	// DeleteChannels is used to delete all channels.
	DeleteChannels() error

	GetPrivateKeyByActorId() (*Channels, error)
}

type Channels

type Channels struct {
	gorm.Model

	// ActorId Since the Actor of ActivityPub is to be used as the data source of the Channel,
	// the ActorId needs to be saved here.
	ActorId uint `gorm:"primaryKey;type:bigint;actor_id"`

	// CreatorId Store the creator's ActorID in Channel as the owner of the channel.
	CreatorId uint `gorm:"primaryKey;type:bigint;creator_id"`

	// The current Channel design differs from the account design in that there is no privacy in the Channel.
	// So the key will be generated by the server and stored in the database.
	// The public key will be saved in the Actor table when the actor is created
	// And the private key will be saved in the Channel.
	PrivateKey string `gorm:"private_key;type:text;private_key"`
}

func NewChannelActorId

func NewChannelActorId(id uint) *Channels

func NewChannels

func NewChannels(ActorId, creatorId uint, privateKey string) *Channels

NewChannels channels constructor. The channel can be created by this constructor.

func NewChannelsCreatorId

func NewChannelsCreatorId(creatorId uint) *Channels

NewChannelsCreatorId Constructing the creator ID (actorId).

func NewChannelsDelete

func NewChannelsDelete(channelId, creatorId uint) *Channels

NewChannelsDelete Delete the constructor of the method.

func (*Channels) CreateChannel

func (c *Channels) CreateChannel() error

func (*Channels) DeleteChannel

func (c *Channels) DeleteChannel() error

func (*Channels) DeleteChannels

func (c *Channels) DeleteChannels() error

func (*Channels) GetChannels

func (c *Channels) GetChannels() ([]*Channels, error)

func (*Channels) GetPrivateKeyByActorId

func (c *Channels) GetPrivateKeyByActorId() (*Channels, error)

type Subscribe

type Subscribe interface {
	IsSubscriber() (bool, error)
	AddSubscriber(adminId uint) error
	GetSubscribers(adminId uint) ([]*Subscribes, error)
	RemoveSubscriber(adminId uint) error
	Subscription() error
	Unsubscribe() error
}

type Subscribes

type Subscribes struct {
	gorm.Model

	ChannelId    uint `gorm:"primaryKey;channel_id"`
	SubscriberId uint `gorm:"primaryKey;subscriber_id"`
}

func NewSubscribe

func NewSubscribe(channelId, subscriberId uint) *Subscribes

func NewSubscriberChannelId

func NewSubscriberChannelId(channelId uint) *Subscribes

func (*Subscribes) AddSubscriber

func (sub *Subscribes) AddSubscriber(adminId uint) error

func (*Subscribes) GetSubscribers

func (sub *Subscribes) GetSubscribers(adminId uint) ([]*Subscribes, error)

func (*Subscribes) IsSubscriber

func (sub *Subscribes) IsSubscriber() (bool, error)

func (*Subscribes) RemoveSubscriber

func (sub *Subscribes) RemoveSubscriber(adminId uint) error

func (*Subscribes) Subscription

func (sub *Subscribes) Subscription() error

func (*Subscribes) Unsubscribe

func (sub *Subscribes) Unsubscribe() error

Jump to

Keyboard shortcuts

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