fix(build): make build-web works; gofmt all Go files
This commit is contained in:
@@ -18,7 +18,7 @@ docs:
|
|||||||
|
|
||||||
# Build the web frontend
|
# Build the web frontend
|
||||||
build-web:
|
build-web:
|
||||||
cd web && [ -s ~/.nvm/nvm.sh ] && . ~/.nvm/nvm.sh && npm run build || (cd web && npm run build)
|
cd web && ([ -s ~/.nvm/nvm.sh ] && . ~/.nvm/nvm.sh && npm run build || npm run build)
|
||||||
|
|
||||||
# Run the server locally (dev mode)
|
# Run the server locally (dev mode)
|
||||||
run: build-server
|
run: build-server
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@ import (
|
|||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/giphy"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/giphy"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/invite"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/invite"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/message"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/message"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/moderation"
|
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/middleware"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/middleware"
|
||||||
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/moderation"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/permissions"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/permissions"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/push"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/push"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/reaction"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/reaction"
|
||||||
@@ -250,7 +250,7 @@ func main() {
|
|||||||
r.Use(middleware.RateLimit(2, 5))
|
r.Use(middleware.RateLimit(2, 5))
|
||||||
r.Post("/", inviteHandler.Join)
|
r.Post("/", inviteHandler.Join)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// File serving (public, for viewing uploaded files)
|
// File serving (public, for viewing uploaded files)
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ import (
|
|||||||
|
|
||||||
// APIClient wraps HTTP calls to the dumpster server.
|
// APIClient wraps HTTP calls to the dumpster server.
|
||||||
type APIClient struct {
|
type APIClient struct {
|
||||||
BaseURL string
|
BaseURL string
|
||||||
HTTP *http.Client
|
HTTP *http.Client
|
||||||
SessionToken string
|
SessionToken string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -3,18 +3,18 @@ package main
|
|||||||
import "github.com/charmbracelet/bubbles/key"
|
import "github.com/charmbracelet/bubbles/key"
|
||||||
|
|
||||||
type keyMap struct {
|
type keyMap struct {
|
||||||
Up key.Binding
|
Up key.Binding
|
||||||
Down key.Binding
|
Down key.Binding
|
||||||
Top key.Binding
|
Top key.Binding
|
||||||
Bottom key.Binding
|
Bottom key.Binding
|
||||||
Tab key.Binding
|
Tab key.Binding
|
||||||
ShiftTab key.Binding
|
ShiftTab key.Binding
|
||||||
FocusInput key.Binding
|
FocusInput key.Binding
|
||||||
Unfocus key.Binding
|
Unfocus key.Binding
|
||||||
Quit key.Binding
|
Quit key.Binding
|
||||||
Help key.Binding
|
Help key.Binding
|
||||||
Send key.Binding
|
Send key.Binding
|
||||||
MemberToggle key.Binding
|
MemberToggle key.Binding
|
||||||
ChannelPicker key.Binding
|
ChannelPicker key.Binding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -53,8 +53,8 @@ var (
|
|||||||
BorderForeground(aqua)
|
BorderForeground(aqua)
|
||||||
|
|
||||||
UnfocusedBorder = lipgloss.NewStyle().
|
UnfocusedBorder = lipgloss.NewStyle().
|
||||||
Border(lipgloss.NormalBorder(), false, false, true, false).
|
Border(lipgloss.NormalBorder(), false, false, true, false).
|
||||||
BorderForeground(bgT)
|
BorderForeground(bgT)
|
||||||
|
|
||||||
// Server list
|
// Server list
|
||||||
ServerActive = lipgloss.NewStyle().
|
ServerActive = lipgloss.NewStyle().
|
||||||
|
|||||||
+6
-6
@@ -4,12 +4,12 @@ package main
|
|||||||
|
|
||||||
// VoiceState holds the current voice connection state.
|
// VoiceState holds the current voice connection state.
|
||||||
type VoiceState struct {
|
type VoiceState struct {
|
||||||
Connected bool
|
Connected bool
|
||||||
RoomName string
|
RoomName string
|
||||||
LiveKitURL string
|
LiveKitURL string
|
||||||
Token string
|
Token string
|
||||||
Muted bool
|
Muted bool
|
||||||
Deafened bool
|
Deafened bool
|
||||||
Participants []VoiceParticipant
|
Participants []VoiceParticipant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
// Handler handles direct-message conversations.
|
// Handler handles direct-message conversations.
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
hub *gateway.Hub
|
hub *gateway.Hub
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,14 +256,14 @@ func (h *Handler) buildResponse(ctx context.Context, convID string) (conversatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
type messageResponse struct {
|
type messageResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
ConversationID string `json:"conversation_id"`
|
ConversationID string `json:"conversation_id"`
|
||||||
AuthorID string `json:"author_id"`
|
AuthorID string `json:"author_id"`
|
||||||
AuthorName string `json:"author_username"`
|
AuthorName string `json:"author_username"`
|
||||||
DisplayName *string `json:"author_display_name"`
|
DisplayName *string `json:"author_display_name"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
EditedAt *string `json:"edited_at"`
|
EditedAt *string `json:"edited_at"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMessages lists messages in a conversation.
|
// ListMessages lists messages in a conversation.
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
|
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/embed"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/embed"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/gateway"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/gateway"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/moderation"
|
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/middleware"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/middleware"
|
||||||
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/moderation"
|
||||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/push"
|
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/push"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
)
|
)
|
||||||
@@ -136,8 +136,8 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusTooManyRequests)
|
w.WriteHeader(http.StatusTooManyRequests)
|
||||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||||
"error": "slowmode",
|
"error": "slowmode",
|
||||||
"retry_after": retryAfter,
|
"retry_after": retryAfter,
|
||||||
"retry_after_ms": retryAfter * 1000,
|
"retry_after_ms": retryAfter * 1000,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,28 +2,28 @@ package permissions
|
|||||||
|
|
||||||
// Permission bitflags.
|
// Permission bitflags.
|
||||||
const (
|
const (
|
||||||
VIEW_CHANNEL int64 = 1 << 0
|
VIEW_CHANNEL int64 = 1 << 0
|
||||||
SEND_MESSAGES int64 = 1 << 1
|
SEND_MESSAGES int64 = 1 << 1
|
||||||
MANAGE_MESSAGES int64 = 1 << 2
|
MANAGE_MESSAGES int64 = 1 << 2
|
||||||
KICK_MEMBERS int64 = 1 << 3
|
KICK_MEMBERS int64 = 1 << 3
|
||||||
BAN_MEMBERS int64 = 1 << 4
|
BAN_MEMBERS int64 = 1 << 4
|
||||||
MANAGE_SERVER int64 = 1 << 5
|
MANAGE_SERVER int64 = 1 << 5
|
||||||
MANAGE_CHANNELS int64 = 1 << 6
|
MANAGE_CHANNELS int64 = 1 << 6
|
||||||
ADMINISTRATOR int64 = 1 << 7
|
ADMINISTRATOR int64 = 1 << 7
|
||||||
CONNECT_VOICE int64 = 1 << 8
|
CONNECT_VOICE int64 = 1 << 8
|
||||||
SPEAK_VOICE int64 = 1 << 9
|
SPEAK_VOICE int64 = 1 << 9
|
||||||
SHARE_SCREEN int64 = 1 << 10
|
SHARE_SCREEN int64 = 1 << 10
|
||||||
MUTE_MEMBERS int64 = 1 << 11
|
MUTE_MEMBERS int64 = 1 << 11
|
||||||
CREATE_INSTANT_INVITE int64 = 1 << 12
|
CREATE_INSTANT_INVITE int64 = 1 << 12
|
||||||
CHANGE_NICKNAME int64 = 1 << 13
|
CHANGE_NICKNAME int64 = 1 << 13
|
||||||
MANAGE_NICKNAMES int64 = 1 << 14
|
MANAGE_NICKNAMES int64 = 1 << 14
|
||||||
MANAGE_ROLES int64 = 1 << 15
|
MANAGE_ROLES int64 = 1 << 15
|
||||||
MANAGE_WEBHOOKS int64 = 1 << 16
|
MANAGE_WEBHOOKS int64 = 1 << 16
|
||||||
EMBED_LINKS int64 = 1 << 17
|
EMBED_LINKS int64 = 1 << 17
|
||||||
ATTACH_FILES int64 = 1 << 18
|
ATTACH_FILES int64 = 1 << 18
|
||||||
ADD_REACTIONS int64 = 1 << 19
|
ADD_REACTIONS int64 = 1 << 19
|
||||||
USE_EXTERNAL_EMOJIS int64 = 1 << 20
|
USE_EXTERNAL_EMOJIS int64 = 1 << 20
|
||||||
MENTION_EVERYONE int64 = 1 << 21
|
MENTION_EVERYONE int64 = 1 << 21
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultEveryonePermissions is granted to the @everyone role when a server is created.
|
// DefaultEveryonePermissions is granted to the @everyone role when a server is created.
|
||||||
|
|||||||
@@ -183,8 +183,6 @@ func (h *Handler) SendPush(ctx context.Context, userID string, payload map[strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SendChannelNotification sends a push notification to all server members (except the author)
|
// SendChannelNotification sends a push notification to all server members (except the author)
|
||||||
// when a new message is posted in a channel.
|
// when a new message is posted in a channel.
|
||||||
func (h *Handler) SendChannelNotification(ctx context.Context, channelID, authorID, channelName, content string) {
|
func (h *Handler) SendChannelNotification(ctx context.Context, channelID, authorID, channelName, content string) {
|
||||||
@@ -254,6 +252,7 @@ func (h *Handler) SendChannelNotification(ctx context.Context, channelID, author
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateVAPIDKeys generates a new VAPID key pair.
|
// GenerateVAPIDKeys generates a new VAPID key pair.
|
||||||
func GenerateVAPIDKeys() (publicKey, privateKey string, err error) {
|
func GenerateVAPIDKeys() (publicKey, privateKey string, err error) {
|
||||||
privateKeyBytes := make([]byte, 32)
|
privateKeyBytes := make([]byte, 32)
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.hub.BroadcastToServer(serverID, gateway.Event{
|
h.hub.BroadcastToServer(serverID, gateway.Event{
|
||||||
Type: gateway.EventReactionAdd,
|
Type: gateway.EventReactionAdd,
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"reaction": reaction,
|
"reaction": reaction,
|
||||||
"channel_id": channelID,
|
"channel_id": channelID,
|
||||||
"message_id": messageID,
|
"message_id": messageID,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
lksdk "github.com/livekit/server-sdk-go/v2"
|
|
||||||
"github.com/livekit/protocol/auth"
|
"github.com/livekit/protocol/auth"
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
|
lksdk "github.com/livekit/server-sdk-go/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
apiKey string
|
apiKey string
|
||||||
apiSecret string
|
apiSecret string
|
||||||
url string
|
url string
|
||||||
roomClient *lksdk.RoomServiceClient
|
roomClient *lksdk.RoomServiceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ func (c *Client) CreateRoom(name string) (*livekit.Room, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
room, err := c.roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
|
room, err := c.roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
|
||||||
Name: name,
|
Name: name,
|
||||||
EmptyTimeout: 300, // 5 minutes before auto-delete when empty
|
EmptyTimeout: 300, // 5 minutes before auto-delete when empty
|
||||||
MaxParticipants: 20,
|
MaxParticipants: 20,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user