瀏覽代碼

Merge pull request #214 from writeas/fix-hostname-fediverse

Fix fediverse post IDs
pull/218/head
Matt Baer 4 年之前
committed by GitHub
父節點
當前提交
88a3ed7878
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 15 次插入13 次删除
  1. +15
    -13
      posts.go

+ 15
- 13
posts.go 查看文件

@@ -1048,11 +1048,6 @@ func fetchPost(app *App, w http.ResponseWriter, r *http.Request) error {
if err != nil {
return err
}
coll.hostName = app.cfg.App.Host
_, err = apiCheckCollectionPermissions(app, r, coll)
if err != nil {
return err
}
collID = coll.ID
}

@@ -1060,12 +1055,26 @@ func fetchPost(app *App, w http.ResponseWriter, r *http.Request) error {
if err != nil {
return err
}
if coll == nil && p.CollectionID.Valid {
// Collection post is getting fetched by post ID, not coll alias + post slug, so get coll info now.
coll, err = app.db.GetCollectionByID(p.CollectionID.Int64)
if err != nil {
return err
}
}
if coll != nil {
coll.hostName = app.cfg.App.Host
_, err = apiCheckCollectionPermissions(app, r, coll)
if err != nil {
return err
}
}

suspended, err := app.db.IsUserSuspended(p.OwnerID.Int64)
if err != nil {
log.Error("fetch post: %v", err)
return ErrInternalGeneral
}

if suspended {
return ErrPostNotFound
}
@@ -1074,13 +1083,6 @@ func fetchPost(app *App, w http.ResponseWriter, r *http.Request) error {

accept := r.Header.Get("Accept")
if strings.Contains(accept, "application/activity+json") {
// Fetch information about the collection this belongs to
if coll == nil && p.CollectionID.Valid {
coll, err = app.db.GetCollectionByID(p.CollectionID.Int64)
if err != nil {
return err
}
}
if coll == nil {
// This is a draft post; 404 for now
// TODO: return ActivityObject


Loading…
取消
儲存