model

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllAccess = []Access{
	AccessPublic,
	AccessPrivate,
}

Functions

This section is empty.

Types

type Access

type Access string
const (
	AccessPublic  Access = "PUBLIC"
	AccessPrivate Access = "PRIVATE"
)

func (Access) IsValid

func (e Access) IsValid() bool

func (Access) MarshalGQL

func (e Access) MarshalGQL(w io.Writer)

func (Access) String

func (e Access) String() string

func (*Access) UnmarshalGQL

func (e *Access) UnmarshalGQL(v interface{}) error

type AppBadgesConnection added in v0.0.4

type AppBadgesConnection struct {
	PageInfo *PageInfo        `json:"pageInfo"`
	Edges    []*AppBadgesEdge `json:"edges"`
}

type AppBadgesEdge added in v0.0.4

type AppBadgesEdge struct {
	Cursor string `json:"cursor"`
	Node   *Badge `json:"node"`
}

type Author

type Author struct {
	ID         uuid.UUID `json:"id"`
	UserID     uuid.UUID `json:"userId"`
	InstanceID uuid.UUID `json:"instanceId"`
	Roles      []Role    `json:"roles"`
	Name       string    `json:"name"`
	Avatar     string    `json:"avatar"`
	Bio        string    `json:"bio"`
	CreatedAt  time.Time `json:"createdAt"`
	BanReason  *string   `json:"banReason,omitempty"`
}

type Badge added in v0.0.4

type Badge struct {
	Base
	Name string `json:"name"`
	Icon string `json:"icon"`
}

type BadgeInput added in v0.0.4

type BadgeInput struct {
	Name string `json:"name"`
	Icon string `json:"icon"`
}

type Base

type Base struct {
	ID        uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()" copier:"Id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Channel

type Channel struct {
	Base
	AuthorID           uuid.UUID      `json:"authorId" gorm:"type:uuid"`
	Author             *InstanceUser  ``
	Rank               string         `json:"rank"`
	Name               string         `json:"name"`
	InstanceID         uuid.UUID      `json:"instanceId" gorm:"type:uuid" copier:"InstanceId"`
	Instance           *Instance      ``
	Messages           []*Message     `gorm:"constraint:OnDelete:CASCADE;"`
	Publishers         pq.StringArray `json:"publishers" gorm:"type:text[]"`
	Readers            pq.StringArray `json:"readers" gorm:"type:text[]"`
	LastMessageAddedAt *time.Time     `json:"lastMessagedAddedAt"`
	MessageCount       int            `json:"messageCount"`
	IsCategory         bool           `json:"isCategory"`
	IsComments         bool           `json:"isComments"`
}

type ChannelInput

type ChannelInput struct {
	Name       string    `json:"name"`
	InstanceID uuid.UUID `json:"instanceId"`
	Publishers []Role    `json:"publishers"`
	Readers    []Role    `json:"readers"`
	IsCategory bool      `json:"isCategory"`
}

type ChannelMessagesConnection

type ChannelMessagesConnection struct {
	PageInfo *PageInfo              `json:"pageInfo"`
	Edges    []*ChannelMessagesEdge `json:"edges"`
}

type ChannelMessagesEdge

type ChannelMessagesEdge struct {
	Cursor string   `json:"cursor"`
	Node   *Message `json:"node"`
}

type ChannelReorderInput

type ChannelReorderInput struct {
	PrevChannelID *uuid.UUID `json:"prevChannelId,omitempty"`
}

type Instance

type Instance struct {
	Base
	Name        string        `json:"name"`
	Description string        `json:"description"`
	AuthorID    uuid.UUID     `json:"authorId" gorm:"type:uuid" copier:"AuthorID"`
	Author      *InstanceUser `gorm:"constraint:OnDelete:CASCADE;"`
	ReadAccess  string        `json:"readAccess"`
	Icon        string        `json:"icon"`
	// IsGroup          bool            “
	ShowAuthor       bool            `json:"showAuthor"`
	ShowChat         bool            `json:"showChat"`
	ShowComments     bool            `json:"showComments"`
	ShowLikes        bool            `json:"showLikes"`
	LikesCount       int             `json:"likesCount"`
	CommentsCount    int             `json:"commentsCount"`
	Channels         []*Channel      `gorm:"constraint:OnDelete:CASCADE;"`
	Users            []*InstanceUser `gorm:"constraint:OnDelete:CASCADE;"`
	Invites          []*Invite       `gorm:"constraint:OnDelete:CASCADE;"`
	PrimaryChannelID uuid.UUID       `gorm:"type:uuid"`
	PrimaryChannel   *Channel        ``
}

type InstanceAuthorsConnection

type InstanceAuthorsConnection struct {
	PageInfo *PageInfo              `json:"pageInfo"`
	Edges    []*InstanceAuthorsEdge `json:"edges"`
}

type InstanceAuthorsEdge

type InstanceAuthorsEdge struct {
	Cursor string  `json:"cursor"`
	Node   *Author `json:"node"`
}

type InstanceChannelsConnection

type InstanceChannelsConnection struct {
	PageInfo *PageInfo               `json:"pageInfo"`
	Edges    []*InstanceChannelsEdge `json:"edges"`
}

type InstanceChannelsEdge

type InstanceChannelsEdge struct {
	Cursor string   `json:"cursor"`
	Node   *Channel `json:"node"`
}

type InstanceInput

type InstanceInput struct {
	ID           *uuid.UUID `json:"id,omitempty"`
	Name         string     `json:"name"`
	ReadAccess   Access     `json:"readAccess"`
	Icon         string     `json:"icon"`
	Description  string     `json:"description"`
	ShowAuthor   bool       `json:"showAuthor"`
	ShowChat     bool       `json:"showChat"`
	ShowComments bool       `json:"showComments"`
	ShowLikes    bool       `json:"showLikes"`
}

type InstanceLikesConnection

type InstanceLikesConnection struct {
	PageInfo *PageInfo            `json:"pageInfo"`
	Edges    []*InstanceLikesEdge `json:"edges"`
}

type InstanceLikesEdge

type InstanceLikesEdge struct {
	Cursor  string    `json:"cursor"`
	LikedAt time.Time `json:"likedAt"`
	Node    *Author   `json:"node"`
}

type InstancePinInput

type InstancePinInput struct {
	Pinned bool `json:"pinned"`
}

type InstanceReorderInput

type InstanceReorderInput struct {
	PrevInstanceID *uuid.UUID `json:"prevInstanceId,omitempty"`
}

type InstanceUser

type InstanceUser struct {
	Base
	InstanceID uuid.UUID `json:"instanceId" gorm:"type:uuid" copier:"InstanceId"`
	Instance   *Instance
	UserID     uuid.UUID `json:"userId" gorm:"type:uuid" copier:"UserId"`
	User       *User
	Name       string         `json:"name"`
	Avatar     string         `json:"avatar"`
	Bio        string         `json:"bio"`
	Roles      pq.StringArray `json:"roles" gorm:"type:text[]"`
	Rank       string         `json:"rank"`
	Pinned     bool           `json:"pinned"`
	LikedByMe  bool           `json:"likedByMe"`
	LikedAt    *time.Time     `json:"likedAt"`
	BanReason  *string        `json:"banReason"`
	BannedAt   *time.Time     `json:"bannedAt"`
}

type Invite

type Invite struct {
	Base
	InstanceID  uuid.UUID     `json:"instanceId" gorm:"type:uuid" copier:"InstanceId"`
	Instance    *Instance     ``
	AuthorID    uuid.UUID     `json:"authorId" gorm:"type:uuid" copier:"AuthorId"`
	Author      *InstanceUser `gorm:"foreignKey:AuthorID"`
	Code        string        `json:"code"`
	ExpiresAt   *time.Time    `json:"expiresAt"`
	Redemptions *int          `json:"redemptions"`
}

type InviteInput

type InviteInput struct {
	InstanceID  uuid.UUID  `json:"instanceId"`
	ExpiresAt   *time.Time `json:"expiresAt,omitempty"`
	Redemptions *int       `json:"redemptions,omitempty"`
}

type Message

type Message struct {
	Base
	Text             string         `json:"text"`
	AuthorID         uuid.UUID      `json:"authorId" gorm:"type:uuid" copier:"AuthorId"`
	Author           *InstanceUser  ``
	ChannelID        uuid.UUID      `json:"channelId" gorm:"type:uuid" copier:"ChannelId"`
	Channel          *Channel       ``
	RepliedMessageID *uuid.UUID     `json:"repliedMessageId" gorm:"type:uuid" copier:"RepliedMessageId"`
	ImageUrls        pq.StringArray `json:"imageUrls" gorm:"type:text[]"`
}

type MessageInput

type MessageInput struct {
	Text             string     `json:"text"`
	ChannelID        uuid.UUID  `json:"channelId"`
	RepliedMessageID *uuid.UUID `json:"repliedMessageId,omitempty"`
	ImageUrls        []string   `json:"imageUrls,omitempty"`
}

type Notice

type Notice struct {
	Kind                  NoticeKind             `json:"kind"`
	ChannelMessagesEdge   *ChannelMessagesEdge   `json:"channelMessagesEdge,omitempty"`
	UserInstancesEdge     *UserInstancesEdge     `json:"userInstancesEdge,omitempty"`
	InstanceChannelsEdge  *InstanceChannelsEdge  `json:"instanceChannelsEdge,omitempty"`
	InstanceLikesEdge     *InstanceLikesEdge     `json:"instanceLikesEdge,omitempty"`
	UserNotificationsEdge *UserNotificationsEdge `json:"userNotificationsEdge,omitempty"`
	Instance              *Instance              `json:"instance,omitempty"`
	User                  *User                  `json:"user,omitempty"`
	Author                *Author                `json:"author,omitempty"`
	Badge                 *Badge                 `json:"badge,omitempty"`
}

type NoticeKind

type NoticeKind string
const (
	NoticeKindMessageAdded      NoticeKind = "MESSAGE_ADDED"
	NoticeKindMessageRemoved    NoticeKind = "MESSAGE_REMOVED"
	NoticeKindChannelAdded      NoticeKind = "CHANNEL_ADDED"
	NoticeKindChannelUpdated    NoticeKind = "CHANNEL_UPDATED"
	NoticeKindChannelRemoved    NoticeKind = "CHANNEL_REMOVED"
	NoticeKindAuthorUpdated     NoticeKind = "AUTHOR_UPDATED"
	NoticeKindUserUpdated       NoticeKind = "USER_UPDATED"
	NoticeKindInstanceUpdated   NoticeKind = "INSTANCE_UPDATED"
	NoticeKindInstanceRemoved   NoticeKind = "INSTANCE_REMOVED"
	NoticeKindLikeAdded         NoticeKind = "LIKE_ADDED"
	NoticeKindLikeRemoved       NoticeKind = "LIKE_REMOVED"
	NoticeKindNotificationAdded NoticeKind = "NOTIFICATION_ADDED"
	NoticeKindBadgeAdded        NoticeKind = "BADGE_ADDED"
)

func (NoticeKind) IsValid

func (e NoticeKind) IsValid() bool

func (NoticeKind) MarshalGQL

func (e NoticeKind) MarshalGQL(w io.Writer)

func (NoticeKind) String

func (e NoticeKind) String() string

func (*NoticeKind) UnmarshalGQL

func (e *NoticeKind) UnmarshalGQL(v interface{}) error

type Notification

type Notification struct {
	Base
	Kind       string    `json:"kind"`
	UserID     uuid.UUID `json:"userId" gorm:"type:uuid" copier:"UserID"`
	User       *User
	AuthorID   *uuid.UUID    `json:"authorId" gorm:"type:uuid" copier:"AuthorId"`
	Author     *InstanceUser ``
	InstanceID *uuid.UUID    `json:"instanceId" gorm:"type:uuid" copier:"InstanceID"`
	Instance   *Instance     ``
	MessageID  *uuid.UUID    `json:"messageId" gorm:"type:uuid" copier:"MessageID"`
	Message    *Message      ``
	ReplyID    *uuid.UUID    `json:"replyId" gorm:"type:uuid" copier:"ReplyID"`
	Reply      *Message      ``
	BadgeID    *uuid.UUID    `json:"userBadgeId" gorm:"type:uuid" copier:"UserBadgeID"`
	Badge      *Badge        ``
}

type NotificationKind

type NotificationKind string
const (
	NotificationKindLikeAdded    NotificationKind = "LIKE_ADDED"
	NotificationKindCommentAdded NotificationKind = "COMMENT_ADDED"
	NotificationKindReplyAdded   NotificationKind = "REPLY_ADDED"
	NotificationKindBadgeAdded   NotificationKind = "BADGE_ADDED"
)

func (NotificationKind) IsValid

func (e NotificationKind) IsValid() bool

func (NotificationKind) MarshalGQL

func (e NotificationKind) MarshalGQL(w io.Writer)

func (NotificationKind) String

func (e NotificationKind) String() string

func (*NotificationKind) UnmarshalGQL

func (e *NotificationKind) UnmarshalGQL(v interface{}) error

type PageInfo

type PageInfo struct {
	HasPreviousPage bool `json:"hasPreviousPage"`
	HasNextPage     bool `json:"hasNextPage"`
}

type Role

type Role string
const (
	RoleAdmin     Role = "ADMIN"
	RoleModerator Role = "MODERATOR"
	RoleMember    Role = "MEMBER"
	RoleBanned    Role = "BANNED"
	RoleAllUsers  Role = "ALL_USERS"
)

func (Role) IsValid

func (e Role) IsValid() bool

func (Role) MarshalGQL

func (e Role) MarshalGQL(w io.Writer)

func (Role) String

func (e Role) String() string

func (*Role) UnmarshalGQL

func (e *Role) UnmarshalGQL(v interface{}) error

type User

type User struct {
	Base
	UID                 string          `json:"uid"`
	Name                string          `json:"name"`
	Avatar              string          `json:"avatar"`
	Bio                 string          `json:"bio"`
	InstanceUsers       []*InstanceUser ``
	Notifications       []*Notification ``
	ReadNotificationsAt *time.Time      ``
	Badges              []*Badge        `gorm:"many2many:user_badges;"`
}

type UserBadge added in v0.0.4

type UserBadge struct {
	Base
	UserID  uuid.UUID `gorm:"primaryKey"`
	BadgeID uuid.UUID `gorm:"primaryKey"`
	Badge   *Badge    ``
	Count   int       ``
}

func (*UserBadge) BeforeCreate added in v0.0.4

func (u *UserBadge) BeforeCreate(tx *gorm.DB) (err error)

type UserBadgesConnection added in v0.0.4

type UserBadgesConnection struct {
	PageInfo *PageInfo         `json:"pageInfo"`
	Edges    []*UserBadgesEdge `json:"edges"`
}

type UserBadgesEdge added in v0.0.4

type UserBadgesEdge struct {
	Cursor   string    `json:"cursor"`
	Node     *Badge    `json:"node"`
	Count    int       `json:"count"`
	BadgedAt time.Time `json:"badgedAt"`
}

type UserInput

type UserInput struct {
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
	Bio    string `json:"bio"`
}

type UserInstancesConnection

type UserInstancesConnection struct {
	PageInfo *PageInfo            `json:"pageInfo"`
	Edges    []*UserInstancesEdge `json:"edges"`
}

type UserInstancesEdge

type UserInstancesEdge struct {
	Cursor       string    `json:"cursor"`
	Node         *Instance `json:"node"`
	InstanceUser *Author   `json:"instanceUser"`
	LikedByMe    bool      `json:"likedByMe"`
	Rank         string    `json:"rank"`
	Pinned       bool      `json:"pinned"`
}

type UserNotificationsConnection

type UserNotificationsConnection struct {
	PageInfo  *PageInfo                `json:"pageInfo"`
	Edges     []*UserNotificationsEdge `json:"edges"`
	HasUnread bool                     `json:"hasUnread"`
}

type UserNotificationsEdge

type UserNotificationsEdge struct {
	Cursor string        `json:"cursor"`
	Node   *Notification `json:"node"`
}

Jump to

Keyboard shortcuts

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