perms

package
v0.0.0-...-1ad4281 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Post | UploadMedia

Default default permissions

Functions

func Update

func Update(userID int64, perms Perms) error

Update update user's permissions

Types

type Perms

type Perms int64

Perms permissions

const (
	// Post perm allows user to post
	Post Perms = 1 << iota
	// UploadMedia perm allows user to upload media
	UploadMedia
	// Admin perm allows user to perform admin actions
	Admin
)

func Get

func Get(userID int64) (perms Perms, err error)

Get get user's permissions

func (Perms) CanPost

func (p Perms) CanPost() bool

CanPost can user post

func (Perms) CanUploadMedia

func (p Perms) CanUploadMedia() bool

CanUploadMedia can user upload media

func (*Perms) DecodeMsg

func (z *Perms) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Perms) EncodeMsg

func (z Perms) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Perms) IsAdmin

func (p Perms) IsAdmin() bool

IsAdmin is user admin

func (Perms) MarshalMsg

func (z Perms) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Perms) Msgsize

func (z Perms) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Perms) NotZero

func (p Perms) NotZero() bool

NotZero is perms != 0

func (*Perms) UnmarshalMsg

func (z *Perms) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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