kopia lustrzana https://github.com/reiver/greatape
refactor(app): ♻️ ostatus and mime types
rodzic
acdd0f5809
commit
ae3abf5723
|
@ -38,7 +38,7 @@ var Follow = route.New(HttpGet, "/u/:name/follow", func(x IContext) error {
|
|||
|
||||
template := ""
|
||||
for _, link := range webfinger.Links {
|
||||
if link.Rel == "http://ostatus.org/schema/1.0/subscribe" {
|
||||
if link.Rel == OStatusSubscription {
|
||||
template = *link.Template
|
||||
break
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
. "contracts"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"server/mime"
|
||||
"server/route"
|
||||
"strconv"
|
||||
|
||||
|
@ -39,7 +40,7 @@ var Followers = route.New(HttpGet, "/u/:username/followers", func(x IContext) er
|
|||
}
|
||||
|
||||
json, _ := result.Marshal()
|
||||
x.Response().Header("Content-Type", "application/activity+json; charset=utf-8")
|
||||
x.Response().Header("Content-Type", mime.ActivityJsonUtf8)
|
||||
return x.WriteString(string(json))
|
||||
})
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"app/models/types"
|
||||
"config"
|
||||
. "contracts"
|
||||
"server/mime"
|
||||
"server/route"
|
||||
)
|
||||
|
||||
|
@ -28,6 +29,6 @@ var Following = route.New(HttpGet, "/u/:username/following", func(x IContext) er
|
|||
result := activitypub.NewOrderedCollection(id, items, len(items))
|
||||
|
||||
json, _ := result.Marshal()
|
||||
x.Response().Header("Content-Type", "application/activity+json; charset=utf-8")
|
||||
x.Response().Header("Content-Type", mime.ActivityJsonUtf8)
|
||||
return x.WriteString(string(json))
|
||||
})
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"config"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"server/mime"
|
||||
"time"
|
||||
|
||||
"github.com/mazen160/go-random"
|
||||
|
@ -63,7 +64,7 @@ func createActor(user *repos.User) *activitypub.Actor {
|
|||
func createWebfinger(user *repos.User) *activitypub.Webfinger {
|
||||
subject := fmt.Sprintf("acct:%s@%s", user.Username, config.DOMAIN)
|
||||
href := fmt.Sprintf("%s://%s/u/%s", config.PROTOCOL, config.DOMAIN, user.Username)
|
||||
_type := "application/activity+json"
|
||||
_type := mime.ActivityJson
|
||||
template := fmt.Sprintf("%s://%s/authorize_interaction?uri={uri}", config.PROTOCOL, config.DOMAIN)
|
||||
|
||||
return &activitypub.Webfinger{
|
||||
|
@ -77,7 +78,7 @@ func createWebfinger(user *repos.User) *activitypub.Webfinger {
|
|||
Type: &_type,
|
||||
},
|
||||
{
|
||||
Rel: "http://ostatus.org/schema/1.0/subscribe",
|
||||
Rel: OStatusSubscription,
|
||||
Template: &template,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
. "contracts"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"server/mime"
|
||||
"server/route"
|
||||
"time"
|
||||
|
||||
|
@ -154,6 +155,6 @@ var InboxGet = route.New(HttpGet, "/u/:username/inbox", func(x IContext) error {
|
|||
}
|
||||
|
||||
json, _ := outbox.Marshal()
|
||||
x.Response().Header("Content-Type", "application/activity+json; charset=utf-8")
|
||||
x.Response().Header("Content-Type", mime.ActivityJsonUtf8)
|
||||
return x.WriteString(string(json))
|
||||
})
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package routes
|
||||
|
||||
const (
|
||||
OStatusSubscription = "http://ostatus.org/schema/1.0/subscribe"
|
||||
)
|
|
@ -8,6 +8,7 @@ import (
|
|||
. "contracts"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"server/mime"
|
||||
"server/route"
|
||||
"time"
|
||||
|
||||
|
@ -97,6 +98,6 @@ var OutboxGet = route.New(HttpGet, "/u/:username/outbox", func(x IContext) error
|
|||
outbox := activitypub.NewOrderedCollection(id, items, len(items))
|
||||
|
||||
json, _ := outbox.Marshal()
|
||||
x.Response().Header("Content-Type", "application/activity+json; charset=utf-8")
|
||||
x.Response().Header("Content-Type", mime.ActivityJsonUtf8)
|
||||
return x.WriteString(string(json))
|
||||
})
|
||||
|
|
Ładowanie…
Reference in New Issue