added artifacts
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm"
|
||||
@@ -39,6 +40,16 @@ func Receive(db *xorm.Engine, localActor *models.FederationActor, body []byte) e
|
||||
handleAccept(db, localActor, activity)
|
||||
case "Undo":
|
||||
handleUndo(db, localActor, activity)
|
||||
case "Create":
|
||||
if IsCreatePullRequest(body) {
|
||||
// Derive instanceURL from the local actor's APID.
|
||||
instanceURL := extractInstanceURL(localActor.APID)
|
||||
if err := HandleCreatePullRequest(db, body, instanceURL); err != nil {
|
||||
log.Printf("federation: handle Create(PullRequest): %v", err)
|
||||
}
|
||||
} else {
|
||||
log.Printf("federation: received Create activity from %s (non-PR, skipped)", actorAPID)
|
||||
}
|
||||
default:
|
||||
log.Printf("federation: received unhandled activity type %q from %s", actType, actorAPID)
|
||||
}
|
||||
@@ -111,3 +122,13 @@ func mustJSON(v any) string {
|
||||
b, _ := json.Marshal(v)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func extractInstanceURL(apid string) string {
|
||||
// apid is like "https://example.com/users/alice"
|
||||
// Return "https://example.com"
|
||||
parts := strings.SplitN(apid, "/", 4)
|
||||
if len(parts) >= 3 {
|
||||
return parts[0] + "//" + parts[2]
|
||||
}
|
||||
return apid
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user