intermediate parsing web received
This commit is contained in:
parent
4d5d3a8a2b
commit
8aff111336
@ -9,13 +9,20 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type InboxContent struct {
|
||||
// AtContext string `json:"@context"`
|
||||
type CreateObject struct {
|
||||
Actor string `json:"actor"`
|
||||
Cc []string `json:"cc"`
|
||||
Context string `json:"content"`
|
||||
Content string `json:"content"`
|
||||
To []string `json:"to"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type FindType struct {
|
||||
Actor string `json:"actor"`
|
||||
Cc []string `json:"cc"`
|
||||
//Object interface{} `json:"Object"`
|
||||
Object json.RawMessage `json:"Object"`
|
||||
Id string `json:"id"`
|
||||
//Object string `json:"object"`
|
||||
Published string `json:"published"`
|
||||
To []string `json:"to"`
|
||||
Type string `json:"type"`
|
||||
@ -93,11 +100,36 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var q InboxContent
|
||||
err = json.Unmarshal(body, &q)
|
||||
fmt.Println(err)
|
||||
fmt.Println(q.Cc)
|
||||
fmt.Println(q)
|
||||
var findtype FindType
|
||||
err = json.Unmarshal(body, &findtype)
|
||||
|
||||
fmt.Println(findtype.Type)
|
||||
|
||||
switch findtype.Type {
|
||||
case "Create":
|
||||
var createobject CreateObject
|
||||
|
||||
err = json.Unmarshal(findtype.Object, &createobject)
|
||||
if err != nil {
|
||||
fmt.Println("Ignore the post here")
|
||||
}
|
||||
fmt.Println("Content: ", createobject.Content)
|
||||
case "Like":
|
||||
case "Announcement":
|
||||
case "Delete":
|
||||
case "Undo":
|
||||
default:
|
||||
fmt.Println("Others --> " + findtype.Type)
|
||||
}
|
||||
|
||||
fmt.Println("Actor: ", findtype.Actor)
|
||||
fmt.Println("Cc: ", findtype.Cc)
|
||||
fmt.Println("Id: ", findtype.Id)
|
||||
fmt.Println("Published: ", findtype.Published)
|
||||
fmt.Println("To: ", findtype.To)
|
||||
fmt.Println("Type: ", findtype.Type)
|
||||
|
||||
fmt.Println("Object: ", string(findtype.Object))
|
||||
}
|
||||
|
||||
func users_fedilogue_followers(w http.ResponseWriter, r *http.Request) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user