Documentation
¶
Index ¶
- Constants
- Variables
- func AuthenticateUser(user *User, password string) error
- type ArchivedMessage
- type Channel
- type Clip
- type ClipFolder
- type Device
- type File
- type FileACLEntry
- type HeartbeatStatus
- type Message
- type MessageReport
- type MessageStamp
- type Mute
- type Pin
- type Stamp
- type Star
- type Tag
- type Unread
- type User
- type UserAccountStatus
- type UserGroup
- type UserGroupMember
- type UserStampHistory
- type UserStatus
- type UserSubscribeChannel
- type UsersPrivateChannel
- type UsersTag
- type Webhook
- type WebhookBot
- func (w *WebhookBot) GetBotUserID() uuid.UUID
- func (w *WebhookBot) GetChannelID() uuid.UUID
- func (w *WebhookBot) GetCreatedAt() time.Time
- func (w *WebhookBot) GetCreatorID() uuid.UUID
- func (w *WebhookBot) GetDescription() string
- func (w *WebhookBot) GetID() uuid.UUID
- func (w *WebhookBot) GetName() string
- func (w *WebhookBot) GetUpdatedAt() time.Time
- func (*WebhookBot) TableName() string
Constants ¶
const ( // DirectMessageChannelRootID ダイレクトメッセージチャンネルの親チャンネルID DirectMessageChannelRootID = "aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaaaa" // MaxChannelDepth チャンネルの深さの最大 MaxChannelDepth = 5 )
const ( // FileTypeUserFile ユーザーアップロードファイルタイプ FileTypeUserFile = "" // FileTypeIcon ユーザーアイコンファイルタイプ FileTypeIcon = "icon" // FileTypeStamp スタンプファイルタイプ FileTypeStamp = "stamp" // FileTypeThumbnail サムネイルファイルタイプ FileTypeThumbnail = "thumbnail" )
Variables ¶
var ( // Tables データベースのテーブルモデル // モデルを追加したら各自ここに追加しなければいけない // **順番注意** Tables = []interface{}{ &Mute{}, &MessageReport{}, &WebhookBot{}, &MessageStamp{}, &Stamp{}, &Clip{}, &ClipFolder{}, &UsersTag{}, &Unread{}, &Star{}, &Device{}, &Pin{}, &FileACLEntry{}, &File{}, &UsersPrivateChannel{}, &UserSubscribeChannel{}, &Tag{}, &ArchivedMessage{}, &Message{}, &Channel{}, &UserGroupMember{}, &UserGroup{}, &User{}, } // Constraints 外部キー制約 Constraints = [][5]string{ {"users_private_channels", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"users_private_channels", "channel_id", "channels(id)", "CASCADE", "CASCADE"}, {"messages", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"messages", "channel_id", "channels(id)", "CASCADE", "CASCADE"}, {"users_tags", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"users_tags", "tag_id", "tags(id)", "CASCADE", "CASCADE"}, {"unreads", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"unreads", "message_id", "messages(id)", "CASCADE", "CASCADE"}, {"devices", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"stars", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"stars", "channel_id", "channels(id)", "CASCADE", "CASCADE"}, {"users_subscribe_channels", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"users_subscribe_channels", "channel_id", "channels(id)", "CASCADE", "CASCADE"}, {"clips", "folder_id", "clip_folders(id)", "CASCADE", "CASCADE"}, {"clips", "message_id", "messages(id)", "CASCADE", "CASCADE"}, {"clips", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"clip_folders", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"pins", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"pins", "message_id", "messages(id)", "CASCADE", "CASCADE"}, {"messages_stamps", "message_id", "messages(id)", "CASCADE", "CASCADE"}, {"messages_stamps", "stamp_id", "stamps(id)", "CASCADE", "CASCADE"}, {"messages_stamps", "user_id", "users(id)", "CASCADE", "CASCADE"}, {"webhook_bots", "bot_user_id", "users(id)", "CASCADE", "CASCADE"}, } )
var ( // ErrUserBotTryLogin : ユーザーエラー botユーザーでログインを試みました。botユーザーはログインできません。 ErrUserBotTryLogin = errors.New("bot user is not allowed to login") // ErrUserWrongIDOrPassword : ユーザーエラー IDかパスワードが間違っています。 ErrUserWrongIDOrPassword = errors.New("password or id is wrong") )
Functions ¶
func AuthenticateUser ¶
AuthenticateUser ユーザー構造体とパスワードを照合します
Types ¶
type ArchivedMessage ¶
type ArchivedMessage struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
MessageID uuid.UUID `gorm:"type:char(36);not null;index"`
UserID uuid.UUID `gorm:"type:char(36);not null"`
Text string `gorm:"type:text;not null"`
DateTime time.Time `gorm:"precision:6"`
}
ArchivedMessage 編集前のアーカイブ化されたメッセージの構造体
func (*ArchivedMessage) TableName ¶
func (am *ArchivedMessage) TableName() string
TableName ArchivedMessage構造体のテーブル名
type Channel ¶
type Channel struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
Name string `gorm:"type:varchar(20);not null;unique_index:name_parent" validate:"channel,required"`
ParentID uuid.UUID `gorm:"type:char(36);not null;unique_index:name_parent"`
Topic string `gorm:"type:text;not null"`
IsForced bool `gorm:"type:boolean;not null;default:false"`
IsPublic bool `gorm:"type:boolean;not null;default:false"`
IsVisible bool `gorm:"type:boolean;not null;default:false"`
CreatorID uuid.UUID `gorm:"type:char(36);not null"`
UpdaterID uuid.UUID `gorm:"type:char(36);not null"`
CreatedAt time.Time `gorm:"precision:6"`
UpdatedAt time.Time `gorm:"precision:6"`
DeletedAt *time.Time `gorm:"precision:6"`
}
Channel チャンネルの構造体
func (*Channel) IsDMChannel ¶
IsDMChannel ダイレクトメッセージ用チャンネルかどうかを返します
type Clip ¶
type Clip struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
UserID uuid.UUID `gorm:"type:char(36);not null;unique_index:user_message"`
MessageID uuid.UUID `gorm:"type:char(36);not null;unique_index:user_message"`
Message Message `gorm:"association_autoupdate:false;association_autocreate:false"`
FolderID uuid.UUID `gorm:"type:char(36);not null"`
CreatedAt time.Time `gorm:"precision:6"`
UpdatedAt time.Time `gorm:"precision:6"`
}
Clip clipの構造体
type ClipFolder ¶
type ClipFolder struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key" json:"id"`
UserID uuid.UUID `gorm:"type:char(36);not null;unique_index:user_folder" json:"-"`
Name string `gorm:"type:varchar(30);not null;unique_index:user_folder" validate:"max=30,required" json:"name"`
CreatedAt time.Time `gorm:"precision:6" json:"createdAt"`
UpdatedAt time.Time `gorm:"precision:6" json:"-"`
}
ClipFolder クリップフォルダの構造体
type Device ¶
type Device struct {
Token string `gorm:"type:varchar(190);not null;primary_key"`
UserID uuid.UUID `gorm:"type:char(36);not null;index"`
CreatedAt time.Time `gorm:"precision:6"`
}
Device 通知デバイスの構造体
type File ¶
type File struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key" json:"fileId"`
Name string `gorm:"type:text;not null" json:"name" validate:"required"`
Mime string `gorm:"type:text;not null" json:"mime" validate:"required"`
Size int64 `gorm:"type:bigint;not null" json:"size" validate:"min=0,required"`
CreatorID uuid.UUID `gorm:"type:char(36);not null" json:"-"`
Hash string `gorm:"type:char(32);not null" json:"md5" validate:"max=32"`
Type string `gorm:"type:varchar(30);not null;default:''" json:"-"`
HasThumbnail bool `gorm:"type:boolean;not null;default:false" json:"hasThumb"`
ThumbnailWidth int `gorm:"type:int;not null;default:0" json:"thumbWidth,omitempty" validate:"min=0"`
ThumbnailHeight int `gorm:"type:int;not null;default:0" json:"thumbHeight,omitempty" validate:"min=0"`
CreatedAt time.Time `gorm:"precision:6" json:"datetime"`
DeletedAt *time.Time `gorm:"precision:6" json:"-"`
}
File DBに格納するファイルの構造体
func (*File) GetThumbKey ¶
GetThumbKey ファイルのサムネイルのストレージに対するキーを返す
type FileACLEntry ¶
type FileACLEntry struct {
FileID uuid.UUID `gorm:"type:char(36);primary_key;not null"`
UserID uuid.NullUUID `gorm:"type:char(36);primary_key;not null"`
Allow sql.NullBool `gorm:"not null"`
}
FileACLEntry ファイルアクセスコントロールリストエントリー構造体
func (*FileACLEntry) TableName ¶
func (f *FileACLEntry) TableName() string
TableName FileACLEntry構造体のテーブル名
type HeartbeatStatus ¶
type HeartbeatStatus struct {
UserStatuses []*UserStatus `json:"userStatuses"`
ChannelID uuid.UUID `json:"channelId"`
}
HeartbeatStatus Heartbeatの状態
type Message ¶
type Message struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
UserID uuid.UUID `gorm:"type:char(36);not null;"`
ChannelID uuid.UUID `gorm:"type:char(36);not null;index"`
Text string `gorm:"type:text;not null" validate:"required"`
CreatedAt time.Time `gorm:"precision:6;index"`
UpdatedAt time.Time `gorm:"precision:6"`
DeletedAt *time.Time `gorm:"precision:6;index"`
}
Message データベースに格納するmessageの構造体
type MessageReport ¶
type MessageReport struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key" json:"id"`
MessageID uuid.UUID `gorm:"type:char(36);not null;unique_index:message_reporter" json:"messageId"`
Reporter uuid.UUID `gorm:"type:char(36);not null;unique_index:message_reporter" json:"reporter"`
Reason string `gorm:"type:text;not null" json:"reason"`
CreatedAt time.Time `gorm:"precision:6;index" json:"createdAt"`
DeletedAt *time.Time `gorm:"precision:6" json:"-"`
}
MessageReport メッセージレポート構造体
func (*MessageReport) TableName ¶
func (*MessageReport) TableName() string
TableName MessageReport構造体のテーブル名
type MessageStamp ¶
type MessageStamp struct {
MessageID uuid.UUID `gorm:"type:char(36);not null;primary_key;index" json:"-"`
StampID uuid.UUID `gorm:"type:char(36);not null;primary_key" json:"stampId"`
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key" json:"userId"`
Count int `gorm:"type:int;not null" json:"count"`
CreatedAt time.Time `gorm:"precision:6" json:"createdAt"`
UpdatedAt time.Time `gorm:"precision:6;index" json:"updatedAt"`
}
MessageStamp メッセージスタンプ構造体
type Mute ¶
type Mute struct {
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}
Mute ミュートチャンネルのレコード
type Pin ¶
type Pin struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
MessageID uuid.UUID `gorm:"type:char(36);not null;unique"`
Message Message `gorm:"association_autoupdate:false;association_autocreate:false"`
UserID uuid.UUID `gorm:"type:char(36);not null"`
CreatedAt time.Time `gorm:"precision:6"`
}
Pin ピン留めのレコード
type Stamp ¶
type Stamp struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key" json:"id"`
Name string `gorm:"type:varchar(32);not null;unique" json:"name" validate:"name,required"`
CreatorID uuid.UUID `gorm:"type:char(36);not null" json:"creatorId"`
FileID uuid.UUID `gorm:"type:char(36);not null" json:"fileId"`
CreatedAt time.Time `gorm:"precision:6" json:"createdAt"`
UpdatedAt time.Time `gorm:"precision:6" json:"updatedAt"`
DeletedAt *time.Time `gorm:"precision:6" json:"-"`
}
Stamp スタンプ構造体
type Star ¶
type Star struct {
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}
Star starの構造体
type Tag ¶
type Tag struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
Name string `gorm:"type:varchar(30);not null;unique" validate:"required,max=30"`
Restricted bool `gorm:"type:boolean;not null;default:false"`
Type string `gorm:"type:varchar(30);not null;default:''"`
CreatedAt time.Time `gorm:"precision:6"`
UpdatedAt time.Time `gorm:"precision:6"`
}
Tag tag_idの管理をする構造体
type Unread ¶
type Unread struct {
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
MessageID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
CreatedAt time.Time `gorm:"precision:6"`
}
Unread 未読レコード
type User ¶
type User struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
Name string `gorm:"type:varchar(32);not null;unique" validate:"required,name"`
DisplayName string `gorm:"type:varchar(64);not null;default:''" validate:"max=64"`
Password string `gorm:"type:char(128);not null;default:''" validate:"required,max=128"`
Salt string `gorm:"type:char(128);not null;default:''" validate:"required,max=128"`
Icon uuid.UUID `gorm:"type:char(36);not null"`
Status UserAccountStatus `gorm:"type:tinyint;not null;default:0"`
Bot bool `gorm:"type:boolean;not null;default:false"`
Role string `gorm:"type:varchar(30);not null;default:'user'" validate:"required"`
TwitterID string `gorm:"type:varchar(15);not null;default:''" validate:"twitterid"`
LastOnline *time.Time `gorm:"precision:6"`
CreatedAt time.Time `gorm:"precision:6"`
UpdatedAt time.Time `gorm:"precision:6"`
}
User userの構造体
type UserAccountStatus ¶
type UserAccountStatus int
UserAccountStatus ユーザーアカウント状態
const ( // UserAccountStatusDeactivated ユーザーアカウント状態: 凍結 UserAccountStatusDeactivated UserAccountStatus = 0 // UserAccountStatusActive ユーザーアカウント状態: 有効 UserAccountStatusActive UserAccountStatus = 1 // UserAccountStatusSuspended ユーザーアカウント状態: 一時停止 UserAccountStatusSuspended UserAccountStatus = 2 )
type UserGroup ¶
type UserGroup struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
Name string `gorm:"type:varchar(30);not null;unique" validate:"max=30,required"`
Description string `gorm:"type:text;not null"`
Type string `gorm:"type:varchar(30);not null;default:''"`
AdminUserID uuid.UUID `gorm:"type:char(36);not null"`
CreatedAt time.Time `gorm:"precision:6"`
UpdatedAt time.Time `gorm:"precision:6"`
}
UserGroup ユーザーグループ構造体
type UserGroupMember ¶
type UserGroupMember struct {
GroupID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}
UserGroupMember ユーザーグループメンバー構造体
func (*UserGroupMember) TableName ¶
func (*UserGroupMember) TableName() string
TableName UserGroupMember構造体のテーブル名
type UserStampHistory ¶
type UserStampHistory struct {
StampID uuid.UUID `json:"stampId"`
Datetime time.Time `json:"datetime"`
}
UserStampHistory スタンプ履歴構造体
type UserStatus ¶
type UserStatus struct {
UserID uuid.UUID `json:"userId"`
Status string `json:"status"`
LastTime time.Time `json:"-"`
}
UserStatus userの状態
type UserSubscribeChannel ¶
type UserSubscribeChannel struct {
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}
UserSubscribeChannel ユーザー・通知チャンネル対構造体
func (*UserSubscribeChannel) TableName ¶
func (*UserSubscribeChannel) TableName() string
TableName UserNotifiedChannel構造体のテーブル名
type UsersPrivateChannel ¶
type UsersPrivateChannel struct {
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}
UsersPrivateChannel UsersPrivateChannelsの構造体
func (*UsersPrivateChannel) TableName ¶
func (upc *UsersPrivateChannel) TableName() string
TableName テーブル名を指定するメソッド
type UsersTag ¶
type UsersTag struct {
UserID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
TagID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
Tag Tag `gorm:"association_autoupdate:false;association_autocreate:false"`
IsLocked bool `gorm:"type:boolean;not null;default:false"`
CreatedAt time.Time `gorm:"precision:6;index"`
UpdatedAt time.Time `gorm:"precision:6"`
}
UsersTag userTagの構造体
type Webhook ¶
type Webhook interface {
GetID() uuid.UUID
GetBotUserID() uuid.UUID
GetName() string
GetDescription() string
GetChannelID() uuid.UUID
GetCreatorID() uuid.UUID
GetCreatedAt() time.Time
GetUpdatedAt() time.Time
}
Webhook Webhook
type WebhookBot ¶
type WebhookBot struct {
ID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
BotUserID uuid.UUID `gorm:"type:char(36);not null;unique"`
BotUser User `gorm:"foreignkey:BotUserID"`
Description string `gorm:"type:text;not null"`
ChannelID uuid.UUID `gorm:"type:char(36);not null"`
CreatorID uuid.UUID `gorm:"type:char(36);not null"`
CreatedAt time.Time `gorm:"precision:6"`
UpdatedAt time.Time `gorm:"precision:6"`
DeletedAt *time.Time `gorm:"precision:6"`
}
WebhookBot DB用WebhookBot構造体
func (*WebhookBot) GetBotUserID ¶
func (w *WebhookBot) GetBotUserID() uuid.UUID
GetBotUserID WebhookUserのIDを返します
func (*WebhookBot) GetChannelID ¶
func (w *WebhookBot) GetChannelID() uuid.UUID
GetChannelID Webhookのデフォルト投稿チャンネルのIDを返します
func (*WebhookBot) GetCreatedAt ¶
func (w *WebhookBot) GetCreatedAt() time.Time
GetCreatedAt Webhookの作成日時を返します
func (*WebhookBot) GetCreatorID ¶
func (w *WebhookBot) GetCreatorID() uuid.UUID
GetCreatorID Webhookの製作者IDを返します
func (*WebhookBot) GetDescription ¶
func (w *WebhookBot) GetDescription() string
GetDescription Webhookの説明を返します
func (*WebhookBot) GetUpdatedAt ¶
func (w *WebhookBot) GetUpdatedAt() time.Time
GetUpdatedAt Webhookの更新日時を返します