122 lines
2.9 KiB
Go
122 lines
2.9 KiB
Go
package utils
|
|
|
|
const (
|
|
minPassword = "6"
|
|
MinPassword = 6
|
|
maxPassword = "64"
|
|
MaxPassword = 64
|
|
|
|
LenHeaderXAuthorization = 36
|
|
lenHeaderXAuthorization = "36"
|
|
LenUserId = 36
|
|
LenHeaderXApiKey = 36
|
|
LenHeaderBrowserTabSession = 36
|
|
|
|
HeaderXAuthorization = "X-Authorization"
|
|
HeaderXApiKey = "X-Api-Key"
|
|
HeaderBrowserTabSession = "Browser-Tab-Session"
|
|
|
|
SessionExpiresAtTime = 7 * 24 * 60 * 60 // 1 week
|
|
|
|
MaxImageSize = 25 * 1024 * 1024 // 25MB
|
|
MaxVideoSize = 50 * 1024 * 1024 // 50MB
|
|
|
|
ConnectionStateOffline = 0
|
|
ConnectionStateOnline = 1
|
|
)
|
|
|
|
var (
|
|
AcceptedImageFileTypes = []string{
|
|
"image/png",
|
|
"image/jpeg",
|
|
"image/jpg",
|
|
"image/webp"}
|
|
|
|
AcceptedVideoFileTypes = []string{
|
|
"video/mp4",
|
|
"video/webm",
|
|
"video/mkv"}
|
|
)
|
|
|
|
const (
|
|
LessonContentTypeHeader uint8 = 1
|
|
LessonContentTypeText = 2
|
|
LessonContentTypeImage
|
|
)
|
|
|
|
const (
|
|
PermissionTeamInviteNewTeamMember = 1
|
|
PermissionTeamRemoveTeamMember = 2
|
|
)
|
|
|
|
var Permissions = []uint16{
|
|
PermissionTeamInviteNewTeamMember,
|
|
PermissionTeamRemoveTeamMember,
|
|
}
|
|
|
|
const (
|
|
RoleAdminId = "d0f0fa0d-3f3b-438b-a76f-7febeb8aab57"
|
|
RoleModeratorId = "b7359e12-359e-423b-b39c-f0d4069adebc"
|
|
RoleUserId = "a1f084ad-d501-4015-b326-4c5c46fd1c5e"
|
|
)
|
|
|
|
// Permissions for each role
|
|
|
|
var AdminPermissions = Permissions
|
|
|
|
var ModeratorPermissions = []uint16{
|
|
PermissionTeamInviteNewTeamMember,
|
|
}
|
|
|
|
var UserPermissions = []uint16{}
|
|
|
|
var Roles = map[string][]uint16{
|
|
RoleAdminId: AdminPermissions,
|
|
RoleModeratorId: ModeratorPermissions,
|
|
RoleUserId: UserPermissions,
|
|
}
|
|
|
|
// websocket
|
|
|
|
// commands sent to websocket clients
|
|
const (
|
|
SendCmdSettingsUpdated = 1
|
|
SendCmdSettingsUpdatedLogo = 2
|
|
SendCmdSettingsUpdatedBanner = 3
|
|
SendCmdSettingsUpdatedSubdomain = 4
|
|
SendCmdTeamAddedMember = 5
|
|
SendCmdTeamUpdatedMemberRole = 6
|
|
SendCmdTeamDeletedMember = 7
|
|
SendCmdLessonCreated = 8
|
|
SendCmdLessonPreviewTitleUpdated = 9
|
|
SendCmdLessonPreviewThumbnailUpdated = 10
|
|
SendCmdLessonStateUpdated = 11
|
|
SendCmdLessonAddedContent = 12
|
|
SendCmdLessonDeletedContent = 13
|
|
SendCmdLessonContentUpdated = 14
|
|
SendCmdLessonContentUpdatedPosition = 15
|
|
SendCmdLessonContentFileUpdated = 16
|
|
SendCmdUserProfilePictureUpdated = 17
|
|
)
|
|
|
|
// commands received from websocket clients
|
|
const (
|
|
ReceivedCmdSubscribeToTopic = 1
|
|
)
|
|
|
|
const (
|
|
SubscribedTopicLessons = "/lessons"
|
|
SubscribedTopicTeam = "/team"
|
|
SubscribedTopicRoles = "/roles"
|
|
SubscribedTopicSettings = "/settings"
|
|
SubscribedTopicUserProfile = "/user-profile"
|
|
)
|
|
|
|
func SubscribedTopicLessonsId(organizationId string) string {
|
|
return SubscribedTopicLessons + "/" + organizationId
|
|
}
|
|
|
|
func SubscribedTopicLessonsEditorId(organizationId string) string {
|
|
return SubscribedTopicLessons + "/" + organizationId + "/editor"
|
|
}
|