model

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableMemo          = "memo"
	TableResource      = "resource"
	TableReaction      = "reaction"
	TableUser          = "user"
	TableUserSetting   = "user_setting"
	TableSession       = "session"
	TableSystemSetting = "system_setting"
	TableInbox         = "inbox"
	TableAttachment    = "attachment"
)
View Source
const (
	WorkspaceSettingNamePrefix = "workspace/settings/"
	UserNamePrefix             = "users/"
	MemoNamePrefix             = "memos/"
	AttachmentNamePrefix       = "attachments/"
	ReactionNamePrefix         = "reactions/"
	InboxNamePrefix            = "inboxes/"
	IdentityProviderNamePrefix = "identityProviders/"
	ActivityNamePrefix         = "activities/"
	WebhookNamePrefix          = "webhooks/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokensUserSetting added in v0.1.1

type AccessTokensUserSetting struct {
	AccessTokens []*UserAccessToken
}

type Attachment added in v0.1.2

type Attachment struct {
	db.Model

	// UID is the user defined unique identifier for the attachment.
	UID string

	// Standard fields
	CreatorID int32
	// The related memo ID.
	MemoID int64

	// Domain specific fields
	Filename    string
	Blob        []byte
	Type        string
	Size        int64
	StorageType AttachmentStorageType
	Reference   string
	Payload     AttachmentPayload
}

func (Attachment) TableName added in v0.1.2

func (Attachment) TableName() string

type AttachmentPayload added in v0.1.2

type AttachmentPayload struct {
	S3Object *AttachmentPayloadS3Object
}

type AttachmentPayloadS3Object added in v0.1.2

type AttachmentPayloadS3Object struct {
	S3Config *StorageS3Config
	Key      string
	// last_presigned_time is the last time the object was presigned.
	// This is used to determine if the presigned URL is still valid.
	LastPresignedTime time.Time
}

type AttachmentStorageType added in v0.1.2

type AttachmentStorageType string
const (
	// Attachment is stored locally. AKA, local file system.
	AttachmentStorageTypeLocal AttachmentStorageType = "local"
	// Attachment is stored in S3.
	AttachmentStorageTypeS3 AttachmentStorageType = "s3"
	// Attachment is stored in an external storage. The reference is a URL.
	AttachmentStorageTypeExternal AttachmentStorageType = "external"
)

type ClientInfo added in v0.1.1

type ClientInfo struct {
	UserAgent  string
	IPAddress  string
	DeviceType string
	OS         string
	Browser    string
}

type CreateMemoRequest

type CreateMemoRequest struct {
	UserID       int64
	ParentID     int64
	RelationType RelationType
	Visibility   Visibility
	Content      string
	RowStatus    RowStatus
	Location     *MemoPayloadLocation
}

type CreateSessionRequest

type CreateSessionRequest struct {
	Username string
	Password string
}

type CreateUserRequest

type CreateUserRequest struct {
	Username string
	Role     Role
	Email    string
	Nickname string
	Password string
}

type CustomProfile

type CustomProfile struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	LogoURL     string `json:"logo_url"`
	Locale      string `json:"locale"`
	Appearance  string `json:"appearance"`
}

type DeleteMemoRequest added in v0.1.4

type DeleteMemoRequest struct {
	ID  int64
	UID string
}

type FindAttachmentFilter added in v0.1.2

type FindAttachmentFilter struct {
	db.BaseFilter

	ID db.F[int64]
}

type FindInboxFilter added in v0.1.2

type FindInboxFilter struct {
	db.BaseFilter

	ID         db.F[int64]
	SenderID   db.F[int64]
	ReceiverID db.F[int64]
	Status     db.F[string]
}

type FindMemoFilter

type FindMemoFilter struct {
	db.BaseFilter

	ID              db.F[int64]
	UID             db.F[string]
	Pid             db.F[int64]
	ParentIDs       db.F[[]int64]
	CreatorID       db.F[int64]
	ExcludeComments db.F[bool]
	ExcludeContent  db.F[bool]
	Status          db.F[string]

	VisibilityList db.F[[]Visibility]
}

type FindSessionFilter

type FindSessionFilter struct {
	db.BaseFilter

	ID     db.F[int64]
	UserID db.F[int64]
}

type FindSystemSettingFilter

type FindSystemSettingFilter struct {
	db.BaseFilter

	Name db.F[string]
}

type FindUserFilter

type FindUserFilter struct {
	db.BaseFilter

	ID       db.F[int64]
	Username db.F[string]
	Role     db.F[Role]
}

type FindUserSettingFilter added in v0.1.1

type FindUserSettingFilter struct {
	db.BaseFilter

	UserID db.F[int64]
	Key    db.F[UserSettingKey]
}

type GeneralSetting

type GeneralSetting struct {
	// theme is the name of the selected theme.
	// This references a CSS file in the web/public/themes/ directory.
	Theme string
	// disallow_user_registration disallows user registration.
	DisallowUserRegistration bool
	// disallow_password_auth disallows password authentication.
	DisallowPasswordAuth bool
	// additional_script is the additional script.
	AdditionalScript string
	// additional_style is the additional style.
	AdditionalStyle string
	// custom_profile is the custom profile.
	CustomProfile *CustomProfile
	// week_start_day_offset is the week start day offset from Sunday.
	// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
	// Default is Sunday.
	WeekStartDayOffset int
	// disallow_change_username disallows changing username.
	DisallowChangeUsername bool
	// disallow_change_nickname disallows changing nickname.
	DisallowChangeNickname bool
}

type GeneralUserSetting added in v0.1.1

type GeneralUserSetting struct {
	Locale         string
	Appearance     string
	MemoVisibility string
	Theme          string
}

type GetMemoRequest

type GetMemoRequest struct {
	ID  int64
	UID string
}

type GetUserSessionsRequest added in v0.1.3

type GetUserSessionsRequest struct {
	UserID int64
}

type GetUserSettingRequest added in v0.1.1

type GetUserSettingRequest struct {
	UserID int64
	Key    UserSettingKey
}

type GetUserSettingsRequest added in v0.1.1

type GetUserSettingsRequest struct {
}

type Inbox added in v0.1.2

type Inbox struct {
	db.Model

	SenderID   int64
	ReceiverID int64
	ActivityID int64
	Status     string
	Message    string
}

Inbox 收件箱

func (Inbox) TableName added in v0.1.2

func (Inbox) TableName() string

type ListInboxesRequest added in v0.1.2

type ListInboxesRequest struct {
}

type ListMemosRequest

type ListMemosRequest struct {
	Status          RowStatus
	VisibilityList  []Visibility
	ExcludeContent  bool
	ExcludeComments bool
}

type Memo

type Memo struct {
	db.Model

	UID        string
	ParentID   int64
	CreatorID  int64
	Content    string
	Payload    *MemoPayload `gorm:"serializer:json"`
	Pinned     bool
	Visibility Visibility
	RowStatus  RowStatus
}

Memo 笔记

func (Memo) TableName

func (Memo) TableName() string

type MemoPayload

type MemoPayload struct {
	Property *MemoPayloadProperty `json:"property"`
	Location *MemoPayloadLocation `json:"location"`
	Tags     []string             `json:"tags"`
}

type MemoPayloadLocation

type MemoPayloadLocation struct {
	Placeholder string  `json:"placeholder"`
	Latitude    float64 `json:"latitude"`
	Longitude   float64 `json:"longitude"`
}

type MemoPayloadProperty

type MemoPayloadProperty struct {
	HasLink            bool     `json:"has_link"`
	HasTaskList        bool     `json:"has_task_list"`
	HasCode            bool     `json:"has_code"`
	HasIncompleteTasks bool     `json:"has_incomplete_tasks"`
	References         []string `json:"references"`
}

type MemoRelatedSetting

type MemoRelatedSetting struct {
	// disallow_public_visibility disallows set memo as public visibility.
	DisallowPublicVisibility bool
	// display_with_update_time orders and displays memo with update time.
	DisplayWithUpdateTime bool
	// content_length_limit is the limit of content length. Unit is byte.
	ContentLengthLimit int
	// enable_double_click_edit enables editing on double click.
	EnableDoubleClickEdit bool
	// enable_link_preview enables links preview.
	EnableLinkPreview bool
	// reactions is the list of reactions.
	Reactions []string
	// disable_markdown_shortcuts disallow the registration of markdown shortcuts.
	DisableMarkdownShortcuts bool
	// enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW).
	EnableBlurNsfwContent bool
	// nsfw_tags is the list of tags that mark content as NSFW for blurring.
	NsfwTags []string
}

type Reaction

type Reaction struct {
	db.Model

	Type      string
	CreatorID int32
	ContentID string
}

func (Reaction) TableName

func (Reaction) TableName() string

type RelationType

type RelationType string
const (
	RelationReference RelationType = "REFERENCE"
	RelationComment   RelationType = "COMMENT"
)

type ResStorageType

type ResStorageType string
const (
	ResStorageTypeLocal         ResStorageType = "LOCAL"
	ResourceStorageTypeS3       ResStorageType = "S3"
	ResourceStorageTypeExternal ResStorageType = "EXTERNAL"
)

type Resource

type Resource struct {
	db.Model

	UID         string
	MemoID      int64
	CreatorID   int32
	Filename    string
	Blob        []byte
	Type        string
	Size        int64
	StorageType ResStorageType
	Reference   string
	Payload     *MemoPayload `gorm:"serializer:json"`
}

func (Resource) TableName

func (Resource) TableName() string

type RevokeUserSessionRequest added in v0.1.3

type RevokeUserSessionRequest struct {
	UserID    int64
	SessionID string
}

type Role

type Role string

Role is the type of a role.

const (
	// RoleHost is the HOST role.
	RoleHost Role = "HOST"
	// RoleAdmin is the ADMIN role.
	RoleAdmin Role = "ADMIN"
	// RoleUser is the USER role.
	RoleUser Role = "USER"
)

type RowStatus

type RowStatus string
const (
	// Normal is the status for a normal row.
	Normal RowStatus = "NORMAL"
	// Archived is the status for an archived row.
	Archived RowStatus = "ARCHIVED"
)

type Session

type Session struct {
	db.Model

	UserID      int64
	AccessToken string
}

func (Session) TableName

func (Session) TableName() string

type SessionsUserSetting added in v0.1.1

type SessionsUserSetting struct {
	Sessions []*UserSession
}

type StorageS3Config added in v0.1.2

type StorageS3Config struct {
	AccessKeyId     string
	AccessKeySecret string
	Endpoint        string
	Region          string
	Bucket          string
	UsePathStyle    bool
}

type StorageSetting

type StorageSetting struct {
}

type SystemSetting

type SystemSetting struct {
	Name        string
	Value       SystemSettingValue `gorm:"serializer:json"`
	Description string
}

func (SystemSetting) TableName

func (SystemSetting) TableName() string

type SystemSettingValue

type SystemSettingValue struct {
	*GeneralSetting
	*StorageSetting
	*MemoRelatedSetting
}

type UpdateMemoRequest added in v0.1.4

type UpdateMemoRequest struct {
	ID           int64
	UserID       int64
	ParentID     int64
	RelationType RelationType
	Visibility   Visibility
	Content      string
	RowStatus    RowStatus
	Location     *MemoPayloadLocation
}

type UpdateUserRequest

type UpdateUserRequest struct {
	UpdateMask  []string
	ID          int64
	Username    string
	Role        Role
	Email       string
	Nickname    string
	Password    string
	AvatarURL   string
	Description string
	Status      RowStatus
}

type UpdateUserSettingRequest added in v0.1.3

type UpdateUserSettingRequest struct {
	UpdateMask []string
	UserID     int64
	Key        UserSettingKey
	Value      UserSettingValue
}

type User

type User struct {
	db.Model

	// Domain specific fields
	Username     string
	Role         Role
	Email        string
	Nickname     string
	PasswordHash string
	AvatarURL    string
	Description  string
	Status       RowStatus
}

func (User) TableName

func (User) TableName() string

type UserAccessToken added in v0.1.1

type UserAccessToken struct {
	Name        string
	AccessToken string
	Description string
	IssuedAt    time.Time
	ExpiresAt   time.Time
}

type UserSession added in v0.1.1

type UserSession struct {
	Name             string
	SessionID        string
	CreateTime       time.Time
	LastAccessedTime time.Time
	ClientInfo       ClientInfo
}

type UserSetting added in v0.1.1

type UserSetting struct {
	UserID int64
	Key    string
	Value  UserSettingValue `gorm:"serializer:json"`
}

func (UserSetting) TableName added in v0.1.1

func (UserSetting) TableName() string

type UserSettingKey added in v0.1.3

type UserSettingKey string
const (
	UserSettingKeyGeneral      UserSettingKey = "GENERAL"
	UserSettingKeySessions     UserSettingKey = "SESSIONS"
	UserSettingKeyAccessTokens UserSettingKey = "ACCESS_TOKENS"
	UserSettingKeyWebhooks     UserSettingKey = "WEBHOOKS"
)

type UserSettingValue added in v0.1.1

type UserWebhook added in v0.1.1

type UserWebhook struct {
	Name        string
	URL         string
	DisplayName string
	CreateTime  time.Time
	UpdateTime  time.Time
}

type Visibility

type Visibility string

Visibility is the type of a visibility.

const (
	// Public is the PUBLIC visibility.
	Public Visibility = "PUBLIC"
	// Protected is the PROTECTED visibility.
	Protected Visibility = "PROTECTED"
	// Private is the PRIVATE visibility.
	Private Visibility = "PRIVATE"
)

func (Visibility) String

func (v Visibility) String() string

type WebhooksUserSetting added in v0.1.1

type WebhooksUserSetting struct {
	Webhooks []*UserWebhook
}

Jump to

Keyboard shortcuts

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