Add WebSocket types

This commit is contained in:
Elara 2022-12-12 18:11:57 -08:00
parent 6023806f7b
commit 20d99cc702
2 changed files with 40 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package types
import (
"encoding/json"
"fmt"
"net/http"
)
@ -28,5 +29,5 @@ func (le LemmyError) Error() string {
type LemmyWebSocketMsg struct {
Op UserOperation `json:"op"`
Data any `json:"data"`
Data json.RawMessage `json:"data"`
}

37
types/websocket.go Normal file
View File

@ -0,0 +1,37 @@
package types
type UserJoin struct {
Auth string `json:"auth"`
}
type UserJoinResponse struct {
Joined bool `json:"joined"`
LemmyResponse
}
type CommunityJoin struct {
CommunityID int `json:"community_id"`
}
type CommunityJoinResponse struct {
Joined bool `json:"joined"`
LemmyResponse
}
type ModJoin struct {
CommunityID int `json:"community_id"`
}
type ModJoinResponse struct {
Joined bool `json:"joined"`
LemmyResponse
}
type PostJoin struct {
PostID int `json:"post_id"`
}
type PostJoinResponse struct {
Joined bool `json:"joined"`
LemmyResponse
}