Add WebSocket types

This commit is contained in:
Elara 2022-12-12 18:11:57 -08:00
parent 54c27ff977
commit a90e43691d
2 changed files with 40 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package types package types
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
) )
@ -28,5 +29,5 @@ func (le LemmyError) Error() string {
type LemmyWebSocketMsg struct { type LemmyWebSocketMsg struct {
Op UserOperation `json:"op"` 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
}