query

package
v0.0.0-...-048a247 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const EMOTES_QUERY_LIMIT = 300

Variables

This section is empty.

Functions

This section is empty.

Types

type BanMap

type BanMap map[primitive.ObjectID]structures.Ban

BanMap is a map of user IDs to a ban object

func (BanMap) Get

func (bm BanMap) Get(id primitive.ObjectID) structures.Ban

func (BanMap) Has

func (bm BanMap) Has(id primitive.ObjectID) bool

func (BanMap) KeySlice

func (bm BanMap) KeySlice() []primitive.ObjectID

KeySlice returns a slice of user IDs for the ban map

type BanQueryOptions

type BanQueryOptions struct {
	Filter bson.M
}

type BanQueryResult

type BanQueryResult struct {
	All []structures.Ban
	// A list of user IDs which will not have any permissions at all
	NoPermissions BanMap
	// A list of user IDs not allowed to authenticate
	NoAuth BanMap
	// A list of user IDs who own nothing and are happy
	NoOwnership BanMap
	// A list of user IDs in the memory hole
	// (filtered from API results)
	MemoryHole BanMap
}

type InboxMessagesQueryOptions

type InboxMessagesQueryOptions struct {
	Actor               *structures.User
	User                *structures.User // The user to fetch inbox messagesq from
	Limit               int
	AfterID             primitive.ObjectID
	SkipPermissionCheck bool
}

type ManyRolesOptions

type ManyRolesOptions struct {
	DefaultOnly bool
}

type MessageQueryOptions

type MessageQueryOptions struct {
	Actor            *structures.User
	Limit            int
	ReturnUnread     bool
	FilterRecipients []primitive.ObjectID
	Sort             bson.M
}

type ModRequestMessagesQueryOptions

type ModRequestMessagesQueryOptions struct {
	Actor               *structures.User
	Targets             map[structures.ObjectKind]bool
	TargetIDs           []primitive.ObjectID
	Filter              bson.M
	Sort                bson.M
	Limit               int
	SkipPermissionCheck bool
}

type QueriableType

type QueriableType interface {
	structures.User | structures.Emote | structures.EmoteSet | structures.Message[bson.Raw] | structures.Role
}

type Query

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

func New

func New(mongoInst mongo.Instance, redisInst redis.Instance) *Query

func (*Query) Bans

func (q *Query) Bans(ctx context.Context, opt BanQueryOptions) (*BanQueryResult, error)

func (*Query) EmoteChannels

func (q *Query) EmoteChannels(ctx context.Context, emoteID primitive.ObjectID, page int, limit int) ([]structures.User, int64, error)

func (*Query) EmoteSets

func (q *Query) EmoteSets(ctx context.Context, filter bson.M) *QueryResult[structures.EmoteSet]

func (*Query) Emotes

func (q *Query) Emotes(ctx context.Context, filter bson.M) *QueryResult[structures.Emote]

func (*Query) GlobalEmoteSet

func (q *Query) GlobalEmoteSet(ctx context.Context) (structures.EmoteSet, error)

func (*Query) InboxMessages

func (q *Query) InboxMessages(ctx context.Context, opt InboxMessagesQueryOptions) *QueryResult[structures.Message[bson.Raw]]

func (*Query) Messages

func (q *Query) Messages(ctx context.Context, filter bson.M, opt MessageQueryOptions) *QueryResult[structures.Message[bson.Raw]]

func (*Query) ModRequestMessages

func (q *Query) ModRequestMessages(ctx context.Context, opt ModRequestMessagesQueryOptions) *QueryResult[structures.Message[bson.Raw]]

func (*Query) NewBinder

func (q *Query) NewBinder(ctx context.Context) *QueryBinder

func (*Query) Roles

func (q *Query) Roles(ctx context.Context, filter bson.M) ([]structures.Role, error)

func (*Query) SearchEmotes

func (q *Query) SearchEmotes(ctx context.Context, opt SearchEmotesOptions) ([]structures.Emote, int, error)

func (*Query) SearchUsers

func (q *Query) SearchUsers(ctx context.Context, filter bson.M, opts ...UserSearchOptions) ([]structures.User, int, error)

func (*Query) UserEditorOf

func (q *Query) UserEditorOf(ctx context.Context, id primitive.ObjectID) ([]structures.UserEditor, error)

func (*Query) UserEmoteSets

func (q *Query) UserEmoteSets(ctx context.Context, filter bson.M) (map[primitive.ObjectID][]structures.EmoteSet, error)

func (*Query) Users

func (q *Query) Users(ctx context.Context, filter bson.M) *QueryResult[structures.User]

type QueryBinder

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

func (*QueryBinder) MapUsers

func (qb *QueryBinder) MapUsers(users []structures.User, roleEnts ...structures.Entitlement[bson.Raw]) (map[primitive.ObjectID]structures.User, error)

type QueryResult

type QueryResult[T QueriableType] struct {
	// contains filtered or unexported fields
}

func (*QueryResult[T]) Empty

func (qr *QueryResult[T]) Empty() bool

func (*QueryResult[T]) Error

func (qr *QueryResult[T]) Error() error

func (*QueryResult[T]) First

func (qr *QueryResult[T]) First() (T, error)

func (*QueryResult[T]) Index

func (qr *QueryResult[T]) Index(pos int) (T, error)

func (*QueryResult[T]) Items

func (qr *QueryResult[T]) Items() ([]T, error)

func (*QueryResult[T]) Last

func (qr *QueryResult[T]) Last() (T, error)

func (*QueryResult[T]) Total

func (qr *QueryResult[T]) Total() int64

type SearchEmotesFilter

type SearchEmotesFilter struct {
	CaseSensitive *bool  `json:"cs"`
	ExactMatch    *bool  `json:"exm"`
	IgnoreTags    *bool  `json:"ignt"`
	Document      bson.M `json:"doc"`
}

type SearchEmotesOptions

type SearchEmotesOptions struct {
	Query  string
	Page   int
	Limit  int
	Filter *SearchEmotesFilter
	Sort   bson.M
	Actor  *structures.User
}

type UserSearchOptions

type UserSearchOptions struct {
	Page  int
	Limit int
	Query string
	Sort  bson.M
}

Jump to

Keyboard shortcuts

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