chore: byte alignment

pull/249/head
zijiren233 2 years ago
parent aa0dd1a8e2
commit fc04e412cb

@ -19,8 +19,8 @@ func WithTask(f ...BootstrapFunc) BootstrapConf {
}
type Bootstrap struct {
task []BootstrapFunc
ctx context.Context
task []BootstrapFunc
}
func New(conf ...BootstrapConf) *Bootstrap {

@ -94,17 +94,17 @@ const (
)
type AlistSubtitle struct {
Cache *SubtitleDataCache
Name string
URL string
Type string
Cache *SubtitleDataCache
}
type AlistMovieCacheData struct {
Ali *AlistAliCache
URL string
Subtitles []*AlistSubtitle
Provider string
Ali *AlistAliCache
Subtitles []*AlistSubtitle
}
type AlistAliCache struct {

@ -28,9 +28,11 @@ type BilibiliMpdCache struct {
Urls []string
}
type BilibiliSubtitleCache map[string]*struct {
Url string
type BilibiliSubtitleCache map[string]*BilibiliSubtitleCacheItem
type BilibiliSubtitleCacheItem struct {
Srt *refreshcache0.RefreshCache[[]byte]
Url string
}
func NewBilibiliSharedMpdCacheInitFunc(movie *model.Movie) func(ctx context.Context, args *BilibiliUserCache) (*BilibiliMpdCache, error) {
@ -213,21 +215,21 @@ func BilibiliNoSharedMovieCacheInitFunc(ctx context.Context, movie *model.Movie,
}
type bilibiliSubtitleResp struct {
FontSize float64 `json:"font_size"`
FontColor string `json:"font_color"`
BackgroundAlpha float64 `json:"background_alpha"`
BackgroundColor string `json:"background_color"`
Stroke string `json:"Stroke"`
Type string `json:"type"`
Lang string `json:"lang"`
Version string `json:"version"`
FontColor string `json:"font_color"`
BackgroundColor string `json:"background_color"`
Stroke string `json:"Stroke"`
Type string `json:"type"`
Lang string `json:"lang"`
Version string `json:"version"`
Body []struct {
Content string `json:"content"`
From float64 `json:"from"`
To float64 `json:"to"`
Sid int `json:"sid"`
Location int `json:"location"`
Content string `json:"content"`
} `json:"body"`
FontSize float64 `json:"font_size"`
BackgroundAlpha float64 `json:"background_alpha"`
}
func NewBilibiliSubtitleCacheInitFunc(movie *model.Movie) func(ctx context.Context, args *BilibiliUserCache) (BilibiliSubtitleCache, error) {
@ -268,10 +270,7 @@ func BilibiliSubtitleCacheInitFunc(ctx context.Context, movie *model.Movie, args
}
subtitleCache := make(BilibiliSubtitleCache, len(resp.Subtitles))
for k, v := range resp.Subtitles {
subtitleCache[k] = &struct {
Url string
Srt *refreshcache0.RefreshCache[[]byte]
}{
subtitleCache[k] = &BilibiliSubtitleCacheItem{
Url: v,
Srt: refreshcache0.NewRefreshCache[[]byte](func(ctx context.Context) ([]byte, error) {
return translateBilibiliSubtitleToSrt(ctx, v)
@ -379,8 +378,8 @@ func NewBilibiliMovieCache(movie *model.Movie) *BilibiliMovieCache {
type BilibiliUserCache = refreshcache.RefreshCache[*BilibiliUserCacheData, struct{}]
type BilibiliUserCacheData struct {
Cookies []*http.Cookie
Backend string
Cookies []*http.Cookie
}
func NewBilibiliUserCache(userID string) *BilibiliUserCache {

@ -12,10 +12,10 @@ import (
type MapRefreshFunc[T any, A any] func(ctx context.Context, key string, args ...A) (T, error)
type MapCache[T any, A any] struct {
lock sync.RWMutex
cache map[string]*refreshcache.RefreshCache[T, A]
refreshFunc MapRefreshFunc[T, A]
maxAge time.Duration
lock sync.RWMutex
}
func newMapCache[T any, A any](refreshFunc MapRefreshFunc[T, A], maxAge time.Duration) *MapCache[T, A] {

@ -12,10 +12,10 @@ import (
type MapRefreshFunc0[T any] func(ctx context.Context, key string) (T, error)
type MapCache0[T any] struct {
lock sync.RWMutex
cache map[string]*refreshcache0.RefreshCache[T]
refreshFunc MapRefreshFunc0[T]
maxAge time.Duration
lock sync.RWMutex
}
func newMapCache0[T any](refreshFunc MapRefreshFunc0[T], maxAge time.Duration) *MapCache0[T] {

@ -58,19 +58,21 @@ func EmbyAuthorizationCacheWithUserIDInitFunc(userID, serverID string) (*EmbyUse
type EmbySource struct {
URL string
IsTranscode bool
Name string
Subtitles []struct {
URL string
Type string
Name string
Cache *refreshcache0.RefreshCache[[]byte]
}
Subtitles []*EmbySubtitleCache
IsTranscode bool
}
type EmbySubtitleCache struct {
Cache *refreshcache0.RefreshCache[[]byte]
URL string
Type string
Name string
}
type EmbyMovieCacheData struct {
Sources []EmbySource
TranscodeSessionID string
Sources []EmbySource
}
type EmbyMovieCache = refreshcache1.RefreshCache[*EmbyMovieCacheData, *EmbyUserCache]
@ -211,12 +213,7 @@ func NewEmbyMovieCacheInitFunc(movie *model.Movie, subPath string) func(ctx cont
name = msi.DisplayLanguage
}
}
resp.Sources[i].Subtitles = append(resp.Sources[i].Subtitles, struct {
URL string
Type string
Name string
Cache *refreshcache0.RefreshCache[[]byte]
}{
resp.Sources[i].Subtitles = append(resp.Sources[i].Subtitles, &EmbySubtitleCache{
URL: url,
Type: subtutleType,
Name: name,

@ -11,8 +11,8 @@ import (
)
type dbVersion struct {
NextVersion string
Upgrade func(*gorm.DB) error
NextVersion string
}
const CurrentVersion = "0.0.10"

@ -140,13 +140,13 @@ func (p RoomAdminPermission) Remove(permission RoomAdminPermission) RoomAdminPer
type RoomMember struct {
CreatedAt time.Time
UpdatedAt time.Time
UserID string `gorm:"primarykey;type:char(32)"`
RoomID string `gorm:"primarykey;type:char(32)"`
Room *Room `gorm:"foreignKey:RoomID;references:ID"`
Status RoomMemberStatus `gorm:"not null;default:2"`
Role RoomMemberRole `gorm:"not null;default:1"`
Room *Room `gorm:"foreignKey:RoomID;references:ID"`
UserID string `gorm:"primarykey;type:char(32)"`
RoomID string `gorm:"primarykey;type:char(32)"`
Permissions RoomMemberPermission
AdminPermissions RoomAdminPermission
Status RoomMemberStatus `gorm:"not null;default:2"`
Role RoomMemberRole `gorm:"not null;default:1"`
}
var ErrNoPermission = errors.New("no permission")

@ -14,11 +14,11 @@ type Movie struct {
ID string `gorm:"primaryKey;type:char(32)" json:"id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
Position uint `gorm:"not null" json:"-"`
RoomID string `gorm:"not null;index;type:char(32)" json:"-"`
CreatorID string `gorm:"index;type:char(32)" json:"creatorId"`
Childrens []*Movie `gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"-"`
MovieBase `gorm:"embedded;embeddedPrefix:base_" json:"base"`
Childrens []*Movie `gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"-"`
Position uint `gorm:"not null" json:"-"`
}
func (m *Movie) Clone() *Movie {
@ -65,18 +65,18 @@ type MoreSource struct {
}
type MovieBase struct {
VendorInfo VendorInfo `gorm:"embedded;embeddedPrefix:vendor_info_" json:"vendorInfo,omitempty"`
Headers map[string]string `gorm:"serializer:fastjson;type:text" json:"headers,omitempty"`
Subtitles map[string]*Subtitle `gorm:"serializer:fastjson;type:text" json:"subtitles,omitempty"`
Url string `gorm:"type:varchar(8192)" json:"url"`
MoreSources []*MoreSource `gorm:"serializer:fastjson;type:text" json:"moreSources,omitempty"`
Name string `gorm:"not null;type:varchar(256)" json:"name"`
Type string `json:"type"`
ParentID EmptyNullString `gorm:"type:char(32)" json:"parentId"`
MoreSources []*MoreSource `gorm:"serializer:fastjson;type:text" json:"moreSources,omitempty"`
Live bool `json:"live"`
Proxy bool `json:"proxy"`
RtmpSource bool `json:"rtmpSource"`
Type string `json:"type"`
Headers map[string]string `gorm:"serializer:fastjson;type:text" json:"headers,omitempty"`
Subtitles map[string]*Subtitle `gorm:"serializer:fastjson;type:text" json:"subtitles,omitempty"`
VendorInfo VendorInfo `gorm:"embedded;embeddedPrefix:vendor_info_" json:"vendorInfo,omitempty"`
IsFolder bool `json:"isFolder"`
ParentID EmptyNullString `gorm:"type:char(32)" json:"parentId"`
}
func (m *MovieBase) IsM3u8() bool {
@ -168,11 +168,11 @@ const (
)
type VendorInfo struct {
Vendor VendorName `gorm:"type:varchar(32)" json:"vendor"`
Backend string `gorm:"type:varchar(64)" json:"backend"`
Bilibili *BilibiliStreamingInfo `gorm:"embedded;embeddedPrefix:bilibili_" json:"bilibili,omitempty"`
Alist *AlistStreamingInfo `gorm:"embedded;embeddedPrefix:alist_" json:"alist,omitempty"`
Emby *EmbyStreamingInfo `gorm:"embedded;embeddedPrefix:emby_" json:"emby,omitempty"`
Vendor VendorName `gorm:"type:varchar(32)" json:"vendor"`
Backend string `gorm:"type:varchar(64)" json:"backend"`
}
type BilibiliStreamingInfo struct {

@ -34,13 +34,13 @@ type Room struct {
ID string `gorm:"primaryKey;type:char(32)" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
Status RoomStatus `gorm:"not null;default:2"`
Name string `gorm:"not null;uniqueIndex;type:varchar(32)"`
Settings *RoomSettings `gorm:"foreignKey:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"settings"`
Name string `gorm:"not null;uniqueIndex;type:varchar(32)"`
CreatorID string `gorm:"index;type:char(32)"`
HashedPassword []byte
RoomMembers []*RoomMember `gorm:"foreignKey:RoomID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Movies []*Movie `gorm:"foreignKey:RoomID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Status RoomStatus `gorm:"not null;default:2"`
}
func (r *Room) BeforeCreate(tx *gorm.DB) error {
@ -71,22 +71,21 @@ func (r *Room) IsActive() bool {
}
type RoomSettings struct {
ID string `gorm:"primaryKey;type:char(32)" json:"-"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"-"`
Hidden bool `gorm:"default:false" json:"hidden"`
DisableJoinNewUser bool `gorm:"default:false" json:"disable_join_new_user"`
JoinNeedReview bool `gorm:"default:false" json:"join_need_review"`
ID string `gorm:"primaryKey;type:char(32)" json:"-"`
UserDefaultPermissions RoomMemberPermission `json:"user_default_permissions"`
DisableGuest bool `gorm:"default:false" json:"disable_guest"`
GuestPermissions RoomMemberPermission `json:"guest_permissions"`
CanGetMovieList bool `gorm:"default:true" json:"can_get_movie_list"`
CanAddMovie bool `gorm:"default:true" json:"can_add_movie"`
CanDeleteMovie bool `gorm:"default:true" json:"can_delete_movie"`
CanEditMovie bool `gorm:"default:true" json:"can_edit_movie"`
CanSetCurrentMovie bool `gorm:"default:true" json:"can_set_current_movie"`
CanSetCurrentStatus bool `gorm:"default:true" json:"can_set_current_status"`
CanSendChatMessage bool `gorm:"default:true" json:"can_send_chat_message"`
DisableGuest bool `gorm:"default:false" json:"disable_guest"`
JoinNeedReview bool `gorm:"default:false" json:"join_need_review"`
DisableJoinNewUser bool `gorm:"default:false" json:"disable_join_new_user"`
Hidden bool `gorm:"default:false" json:"hidden"`
CanGetMovieList bool `gorm:"default:true" json:"can_get_movie_list"`
CanAddMovie bool `gorm:"default:true" json:"can_add_movie"`
CanDeleteMovie bool `gorm:"default:true" json:"can_delete_movie"`
CanEditMovie bool `gorm:"default:true" json:"can_edit_movie"`
CanSetCurrentMovie bool `gorm:"default:true" json:"can_set_current_movie"`
CanSetCurrentStatus bool `gorm:"default:true" json:"can_set_current_status"`
CanSendChatMessage bool `gorm:"default:true" json:"can_send_chat_message"`
}
func DefaultRoomSettings() *RoomSettings {

@ -39,23 +39,22 @@ func (r Role) String() string {
}
type User struct {
ID string `gorm:"primaryKey;type:char(32)" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
RegisteredByProvider bool `gorm:"not null;default:false"`
RegisteredByEmail bool `gorm:"not null;default:false"`
UserProviders []*UserProvider `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Username string `gorm:"not null;uniqueIndex;type:varchar(32)"`
HashedPassword []byte `gorm:"not null"`
Email EmptyNullString `gorm:"type:varchar(128);uniqueIndex"`
Role Role `gorm:"not null;default:2"`
RoomMembers []*RoomMember `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Rooms []*Room `gorm:"foreignKey:CreatorID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Movies []*Movie `gorm:"foreignKey:CreatorID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
BilibiliVendor *BilibiliVendor `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
AlistVendor []*AlistVendor `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
EmbyVendor []*EmbyVendor `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
ID string `gorm:"primaryKey;type:char(32)" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
Username string `gorm:"not null;uniqueIndex;type:varchar(32)"`
Email EmptyNullString `gorm:"type:varchar(128);uniqueIndex"`
HashedPassword []byte `gorm:"not null"`
BilibiliVendor *BilibiliVendor `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Movies []*Movie `gorm:"foreignKey:CreatorID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
UserProviders []*UserProvider `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
RoomMembers []*RoomMember `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Rooms []*Room `gorm:"foreignKey:CreatorID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
AlistVendor []*AlistVendor `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
EmbyVendor []*EmbyVendor `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
Role Role `gorm:"not null;default:2"`
RegisteredByProvider bool `gorm:"not null;default:false"`
RegisteredByEmail bool `gorm:"not null;default:false"`
autoAddUsernameSuffix bool
}

@ -23,15 +23,14 @@ type Etcd struct {
}
type Backend struct {
Consul Consul `gorm:"embedded;embeddedPrefix:consul_" json:"consul"`
Etcd Etcd `gorm:"embedded;embeddedPrefix:etcd_" json:"etcd"`
Endpoint string `gorm:"primaryKey;type:varchar(512)" json:"endpoint"`
Comment string `gorm:"type:text" json:"comment"`
Tls bool `gorm:"default:false" json:"tls"`
JwtSecret string `gorm:"type:varchar(256)" json:"jwtSecret"`
CustomCA string `gorm:"type:text" json:"customCA"`
TimeOut string `gorm:"default:10s" json:"timeOut"`
Consul Consul `gorm:"embedded;embeddedPrefix:consul_" json:"consul"`
Etcd Etcd `gorm:"embedded;embeddedPrefix:etcd_" json:"etcd"`
Tls bool `gorm:"default:false" json:"tls"`
}
func (b *Backend) Validate() error {
@ -52,18 +51,18 @@ func (b *Backend) Validate() error {
type VendorBackend struct {
CreatedAt time.Time
UpdatedAt time.Time
Backend Backend `gorm:"embedded;embeddedPrefix:backend_" json:"backend"`
UsedBy BackendUsedBy `gorm:"embedded;embeddedPrefix:used_by_" json:"usedBy"`
Backend Backend `gorm:"embedded;embeddedPrefix:backend_" json:"backend"`
}
type BackendUsedBy struct {
BilibiliBackendName string `gorm:"type:varchar(64)" json:"bilibiliBackendName"`
AlistBackendName string `gorm:"type:varchar(64)" json:"alistBackendName"`
EmbyBackendName string `gorm:"type:varchar(64)" json:"embyBackendName"`
Enabled bool `gorm:"default:false" json:"enabled"`
Bilibili bool `gorm:"default:false" json:"bilibili"`
BilibiliBackendName string `gorm:"type:varchar(64)" json:"bilibiliBackendName"`
Alist bool `gorm:"default:false" json:"alist"`
AlistBackendName string `gorm:"type:varchar(64)" json:"alistBackendName"`
Emby bool `gorm:"default:false" json:"emby"`
EmbyBackendName string `gorm:"type:varchar(64)" json:"embyBackendName"`
}
func (v *VendorBackend) BeforeSave(tx *gorm.DB) error {

@ -11,9 +11,9 @@ import (
type BilibiliVendor struct {
CreatedAt time.Time
UpdatedAt time.Time
Cookies map[string]string `gorm:"not null;serializer:fastjson;type:text"`
UserID string `gorm:"primaryKey;type:char(32)"`
Backend string `gorm:"type:varchar(64)"`
Cookies map[string]string `gorm:"not null;serializer:fastjson;type:text"`
}
func (b *BilibiliVendor) BeforeSave(tx *gorm.DB) error {

@ -16,8 +16,8 @@ type Client struct {
r *Room
h *Hub
c chan Message
wg sync.WaitGroup
conn *websocket.Conn
wg sync.WaitGroup
timeOut time.Duration
closed uint32
}

@ -29,10 +29,10 @@ func newCurrent() *current {
}
type Status struct {
lastUpdate time.Time `json:"-"`
CurrentTime float64 `json:"currentTime"`
PlaybackRate float64 `json:"playbackRate"`
IsPlaying bool `json:"isPlaying"`
lastUpdate time.Time `json:"-"`
}
func newStatus() Status {

@ -15,19 +15,18 @@ import (
)
type clients struct {
lock sync.RWMutex
m map[*Client]struct{}
lock sync.RWMutex
}
type Hub struct {
id string
clients rwmap.RWMap[string, *clients]
broadcast chan *broadcastMessage
exit chan struct{}
closed uint32
clients rwmap.RWMap[string, *clients]
id string
wg sync.WaitGroup
once utils.Once
once utils.Once
closed uint32
}
type broadcastMessage struct {

@ -17,11 +17,11 @@ import (
)
type Room struct {
model.Room
current *current
hub atomic.Pointer[Hub]
movies *movies
members rwmap.RWMap[string, *model.RoomMember]
model.Room
}
func (r *Room) lazyInitHub() *Hub {

@ -17,11 +17,11 @@ import (
)
type User struct {
model.User
version uint32
alistCache atomic.Pointer[cache.AlistUserCache]
bilibiliCache atomic.Pointer[cache.BilibiliUserCache]
embyCache atomic.Pointer[cache.EmbyUserCache]
model.User
version uint32
}
func (u *User) AlistCache() *cache.AlistUserCache {

@ -102,11 +102,11 @@ func (p *rainbowGenericProvider) NewAuthURL(ctx context.Context, state string) (
}
type rainbowNewAuthURLResp struct {
Code int `json:"code"`
ErrCode int `json:"errcode"`
Msg string `json:"msg"`
Type string `json:"type"`
URL string `json:"url"`
Code int `json:"code"`
ErrCode int `json:"errcode"`
}
func (p *rainbowGenericProvider) GetUserInfo(ctx context.Context, code string) (*provider.UserInfo, error) {
@ -150,12 +150,12 @@ func (p *rainbowGenericProvider) GetUserInfo(ctx context.Context, code string) (
}
type rainbowUserInfo struct {
Code int `json:"code"`
ErrCode int `json:"errcode"`
Msg string `json:"msg"`
Type string `json:"type"`
SocialUID string `json:"social_uid"`
Nickname string `json:"nickname"`
Code int `json:"code"`
ErrCode int `json:"errcode"`
}
func (r *Rainbow) ExtractProvider(p provider.OAuth2Provider) (provider.ProviderInterface, error) {

@ -2,7 +2,6 @@ package providers
import (
"context"
"fmt"
"net/http"
json "github.com/json-iterator/go"
@ -54,7 +53,7 @@ func (p *DiscordProvider) GetUserInfo(ctx context.Context, code string) (*provid
return nil, err
}
client := p.config.Client(ctx, tk)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("https://discord.com/api/v10/oauth2/@me"), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://discord.com/api/v10/oauth2/@me", nil)
if err != nil {
return nil, err
}

@ -75,8 +75,8 @@ func (p *GiteeProvider) GetUserInfo(ctx context.Context, code string) (*provider
}
type giteeUserInfo struct {
ID uint64 `json:"id"`
Login string `json:"login"`
ID uint64 `json:"id"`
}
func init() {

@ -128,7 +128,6 @@ type qqProviderMe struct {
}
type qqUserInfo struct {
Ret int `json:"ret"`
Msg string `json:"msg"`
Nickname string `json:"nickname"`
Figureurl string `json:"figureurl"`
@ -137,6 +136,7 @@ type qqUserInfo struct {
FigureurlQq1 string `json:"figureurl_qq_1"`
FigureurlQq2 string `json:"figureurl_qq_2"`
Gender string `json:"gender"`
Ret int `json:"ret"`
}
func init() {

@ -23,11 +23,13 @@ type BoolSetting interface {
var _ BoolSetting = (*Bool)(nil)
type Bool struct {
value uint32
beforeInit func(BoolSetting, bool) (bool, error)
beforeSet func(BoolSetting, bool) (bool, error)
afterInit func(BoolSetting, bool)
afterSet func(BoolSetting, bool)
setting
defaultValue bool
beforeInit, beforeSet func(BoolSetting, bool) (bool, error)
afterInit, afterSet func(BoolSetting, bool)
value uint32
defaultValue bool
}
type BoolSettingOption func(*Bool)

@ -24,12 +24,14 @@ type Float64Setting interface {
var _ Float64Setting = (*Float64)(nil)
type Float64 struct {
value uint64
validator func(float64) error
beforeInit func(Float64Setting, float64) (float64, error)
beforeSet func(Float64Setting, float64) (float64, error)
afterInit func(Float64Setting, float64)
afterSet func(Float64Setting, float64)
setting
defaultValue float64
validator func(float64) error
beforeInit, beforeSet func(Float64Setting, float64) (float64, error)
afterInit, afterSet func(Float64Setting, float64)
value uint64
defaultValue float64
}
type Float64SettingOption func(*Float64)

@ -23,12 +23,14 @@ type Int64Setting interface {
var _ Int64Setting = (*Int64)(nil)
type Int64 struct {
value int64
validator func(int64) error
beforeInit func(Int64Setting, int64) (int64, error)
beforeSet func(Int64Setting, int64) (int64, error)
afterInit func(Int64Setting, int64)
afterSet func(Int64Setting, int64)
setting
defaultValue int64
validator func(int64) error
beforeInit, beforeSet func(Int64Setting, int64) (int64, error)
afterInit, afterSet func(Int64Setting, int64)
value int64
defaultValue int64
}
type Int64SettingOption func(*Int64)

@ -14,8 +14,8 @@ var ErrSettingAlreadyInited = errors.New("setting already inited")
var _ heap.Interface[maxHeapItem] = (*maxHeap)(nil)
type maxHeapItem struct {
priority int
Setting
priority int
}
type maxHeap struct {

@ -22,13 +22,15 @@ type StringSetting interface {
var _ StringSetting = (*String)(nil)
type String struct {
validator func(string) error
beforeInit func(StringSetting, string) (string, error)
beforeSet func(StringSetting, string) (string, error)
afterInit func(StringSetting, string)
afterSet func(StringSetting, string)
defaultValue string
value string
setting
defaultValue string
lock sync.RWMutex
value string
validator func(string) error
beforeInit, beforeSet func(StringSetting, string) (string, error)
afterInit, afterSet func(StringSetting, string)
lock sync.RWMutex
}
type StringSettingOption func(*String)

@ -27,8 +27,8 @@ func WaitCbk() {
type SysNotify struct {
c chan os.Signal
once sync.Once
taskGroup rwmap.RWMap[NotifyType, *taskQueue]
once sync.Once
}
type NotifyType int
@ -39,14 +39,14 @@ const (
)
type taskQueue struct {
notifyTaskLock sync.Mutex
notifyTaskQueue *pqueue.PQueue[*sysNotifyTask]
notifyTaskLock sync.Mutex
}
type sysNotifyTask struct {
Task func() error
NotifyType NotifyType
Name string
NotifyType NotifyType
}
func NewSysNotifyTask(name string, NotifyType NotifyType, task func() error) *sysNotifyTask {

@ -18,11 +18,11 @@ import (
)
type m3u8TargetClaims struct {
jwt.RegisteredClaims
RoomId string `json:"r"`
MovieId string `json:"m"`
TargetUrl string `json:"t"`
IsM3u8File bool `json:"f"`
jwt.RegisteredClaims
}
func GetM3u8Target(token string) (*m3u8TargetClaims, error) {

@ -13,16 +13,13 @@ import (
)
type publicSettings struct {
PasswordDisableSignup bool `json:"passwordDisableSignup"`
EmailWhitelist []string `json:"emailWhitelist,omitempty"`
PasswordDisableSignup bool `json:"passwordDisableSignup"`
EmailEnable bool `json:"emailEnable"`
EmailDisableSignup bool `json:"emailDisableSignup"`
EmailWhitelistEnabled bool `json:"emailWhitelistEnabled"`
EmailWhitelist []string `json:"emailWhitelist,omitempty"`
Oauth2DisableSignup bool `json:"oauth2DisableSignup"`
GuestEnable bool `json:"guestEnable"`
Oauth2DisableSignup bool `json:"oauth2DisableSignup"`
GuestEnable bool `json:"guestEnable"`
}
func Settings(ctx *gin.Context) {

@ -36,9 +36,9 @@ var (
)
type AuthClaims struct {
jwt.RegisteredClaims
UserId string `json:"u"`
UserVersion uint32 `json:"uv"`
jwt.RegisteredClaims
}
func authUser(authorization string) (*AuthClaims, error) {

@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
json "github.com/json-iterator/go"
"github.com/synctv-org/synctv/internal/model"
dbModel "github.com/synctv-org/synctv/internal/model"
"google.golang.org/grpc/connectivity"
)
@ -134,7 +133,7 @@ type GetVendorBackendResp struct {
Status connectivity.State `json:"status"`
}
type AddVendorBackendReq model.VendorBackend
type AddVendorBackendReq dbModel.VendorBackend
func (avbr *AddVendorBackendReq) Validate() error {
if avbr.UsedBy.AlistBackendName != "" {

@ -13,9 +13,9 @@ var (
)
type ApiResp struct {
Time int64 `json:"time"`
Error string `json:"error,omitempty"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Time int64 `json:"time"`
}
func (ar *ApiResp) SetError(err error) {

@ -9,13 +9,13 @@ import (
type RoomMembersResp struct {
UserID string `json:"userId"`
Username string `json:"username"`
RoomID string `json:"roomId"`
JoinAt int64 `json:"joinAt"`
OnlineCount int `json:"onlineCount"`
Role dbModel.RoomMemberRole `json:"role"`
Status dbModel.RoomMemberStatus `json:"status"`
RoomID string `json:"roomId"`
Permissions dbModel.RoomMemberPermission `json:"permissions"`
AdminPermissions dbModel.RoomAdminPermission `json:"adminPermissions"`
Role dbModel.RoomMemberRole `json:"role"`
Status dbModel.RoomMemberStatus `json:"status"`
}
type (

@ -198,16 +198,16 @@ type MoviesResp struct {
type Movie struct {
Id string `json:"id"`
CreatedAt int64 `json:"createAt"`
Base model.MovieBase `json:"base"`
Creator string `json:"creator"`
CreatorId string `json:"creatorId"`
SubPath string `json:"subPath"`
Base model.MovieBase `json:"base"`
CreatedAt int64 `json:"createAt"`
}
type CurrentMovieResp struct {
Status op.Status `json:"status"`
Movie *Movie `json:"movie"`
Status op.Status `json:"status"`
ExpireId uint64 `json:"expireId"`
}

@ -7,7 +7,6 @@ import (
json "github.com/json-iterator/go"
"github.com/gin-gonic/gin"
"github.com/synctv-org/synctv/internal/model"
dbModel "github.com/synctv-org/synctv/internal/model"
)
@ -59,14 +58,14 @@ func (c *CreateRoomReq) Validate() error {
}
type RoomListResp struct {
RoomId string `json:"roomId"`
RoomName string `json:"roomName"`
ViewerCount int64 `json:"viewerCount"`
NeedPassword bool `json:"needPassword"`
CreatorID string `json:"creatorId"`
Creator string `json:"creator"`
CreatedAt int64 `json:"createdAt"`
Status model.RoomStatus `json:"status"`
RoomId string `json:"roomId"`
RoomName string `json:"roomName"`
CreatorID string `json:"creatorId"`
Creator string `json:"creator"`
ViewerCount int64 `json:"viewerCount"`
CreatedAt int64 `json:"createdAt"`
NeedPassword bool `json:"needPassword"`
Status dbModel.RoomStatus `json:"status"`
}
type JoinedRoomResp struct {
@ -152,11 +151,11 @@ func (c *CheckRoomPasswordReq) Validate() error {
}
type CheckRoomResp struct {
Name string `json:"name"`
Status model.RoomStatus `json:"status"`
CreatorID string `json:"creatorId"`
Creator string `json:"creator"`
NeedPassword bool `json:"needPassword"`
ViewerCount int64 `json:"viewerCount"`
EnabledGuest bool `json:"enabledGuest"`
Name string `json:"name"`
CreatorID string `json:"creatorId"`
Creator string `json:"creator"`
ViewerCount int64 `json:"viewerCount"`
Status dbModel.RoomStatus `json:"status"`
NeedPassword bool `json:"needPassword"`
EnabledGuest bool `json:"enabledGuest"`
}

@ -113,9 +113,9 @@ func (u *UserSignupPasswordReq) Validate() error {
type UserInfoResp struct {
ID string `json:"id"`
Username string `json:"username"`
Role dbModel.Role `json:"role"`
CreatedAt int64 `json:"createdAt"`
Email string `json:"email"`
CreatedAt int64 `json:"createdAt"`
Role dbModel.Role `json:"role"`
}
type SetUsernameReq struct {

@ -10,8 +10,8 @@ import (
)
type VendorMeResp[T any] struct {
IsLogin bool `json:"isLogin"`
Info T `json:"info,omitempty"`
IsLogin bool `json:"isLogin"`
}
type VendorFSListResp[T any] struct {

@ -12,11 +12,11 @@ import (
type SmtpConfig struct {
Host string
Port uint32
Protocol string
Username string
Password string
From string
Port uint32
}
func validateSmtpConfig(c *SmtpConfig) error {
@ -71,11 +71,11 @@ func newSmtpClient(c *SmtpConfig) (*smtp.Client, error) {
var ErrSmtpPoolClosed = fmt.Errorf("smtp pool is closed")
type SmtpPool struct {
mu sync.Mutex
clients []*smtp.Client
c *SmtpConfig
clients []*smtp.Client
max int
active int
mu sync.Mutex
closed bool
}

Loading…
Cancel
Save