diff --git a/go.mod b/go.mod index f784256e3f..9b8d2863d8 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.18 require ( code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b code.gitea.io/sdk/gitea v0.15.1 + gitea.com/Ta180m/activitypub v0.0.0-20220711172827-b05423b54985 gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb gitea.com/go-chi/cache v0.2.0 gitea.com/go-chi/captcha v0.0.0-20211013065431-70641c1a35d5 @@ -28,7 +29,6 @@ require ( github.com/ethantkoenig/rupture v1.0.1 github.com/felixge/fgprof v0.9.2 github.com/gliderlabs/ssh v0.3.4 - github.com/go-ap/activitypub v0.0.0-20220615144428-48208c70483b github.com/go-ap/jsonld v0.0.0-20220615144122-1d862b15410d github.com/go-chi/chi/v5 v5.0.7 github.com/go-chi/cors v1.2.1 @@ -110,7 +110,7 @@ require ( require ( cloud.google.com/go v0.99.0 // indirect - git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20200411073322-f0bcc40f0bf2 // indirect + git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect github.com/Microsoft/go-winio v0.5.2 // indirect github.com/ProtonMail/go-crypto v0.0.0-20220407094043-a94812496cf5 // indirect @@ -164,7 +164,7 @@ require ( github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fullstorydev/grpcurl v1.8.1 // indirect github.com/fxamacker/cbor/v2 v2.4.0 // indirect - github.com/go-ap/errors v0.0.0-20220615144307-e8bc4a40ae9f // indirect + github.com/go-ap/errors v0.0.0-20220618122732-319f41ac54e1 // indirect github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect github.com/go-enry/go-oniguruma v1.2.1 // indirect github.com/go-git/gcfg v1.5.0 // indirect diff --git a/go.sum b/go.sum index 1032069807..b548b91a5f 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,10 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.5/go.mod h1:aXENhDJ1Y4lIg4EU contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE= contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20200411073322-f0bcc40f0bf2 h1:2OrsyJYZp7J6nyAsKi2q1SELYRaIc0aQmcQ/EQqPfk8= -git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20200411073322-f0bcc40f0bf2/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs= +git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg= +git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs= +gitea.com/Ta180m/activitypub v0.0.0-20220711172827-b05423b54985 h1:mFjFQxAsUdcvtM3klWtTbkhGnsRVF+DPhZPofsKmPlk= +gitea.com/Ta180m/activitypub v0.0.0-20220711172827-b05423b54985/go.mod h1:KDY/LAOthmTlRA4ft9TKrvPKVe+AZaSaU+3HS/UITvU= gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb h1:Yy0Bxzc8R2wxiwXoG/rECGplJUSpXqCsog9PuJFgiHs= gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc= gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0= @@ -462,10 +464,8 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/go-ap/activitypub v0.0.0-20220615144428-48208c70483b h1:+RjYfEfoZdM3wHFs752dlOpGaoRhwRRyQxjajg08LcQ= -github.com/go-ap/activitypub v0.0.0-20220615144428-48208c70483b/go.mod h1:DE3vvc6Didgfd3k7M1Mos6qMDFNmMrxJmYVMHG9h9Io= -github.com/go-ap/errors v0.0.0-20220615144307-e8bc4a40ae9f h1:kJhGo4NApJP0Lt9lkJnfmuTnRWVFbCynY0kiTxpPUR4= -github.com/go-ap/errors v0.0.0-20220615144307-e8bc4a40ae9f/go.mod h1:KHkKFKZvc05lr79+RGoq/zG8YjWi3+FK60Bxd+mpCew= +github.com/go-ap/errors v0.0.0-20220618122732-319f41ac54e1 h1:PkPVIQGt76HHFWSeUINXCfYpEnzlSS+AQyuXi7oJ/gM= +github.com/go-ap/errors v0.0.0-20220618122732-319f41ac54e1/go.mod h1:KHkKFKZvc05lr79+RGoq/zG8YjWi3+FK60Bxd+mpCew= github.com/go-ap/jsonld v0.0.0-20220615144122-1d862b15410d h1:Z/oRXMlZHjvjIqDma1FrIGL3iE5YL7MUI0bwYEZ6qbA= github.com/go-ap/jsonld v0.0.0-20220615144122-1d862b15410d/go.mod h1:jyveZeGw5LaADntW+UEsMjl3IlIwk+DxlYNsbofQkGA= github.com/go-asn1-ber/asn1-ber v1.5.4 h1:vXT6d/FNDiELJnLb6hGNa309LMsrCoYFvpwHDF0+Y1A= diff --git a/integrations/api_activitypub_person_test.go b/integrations/api_activitypub_person_test.go index e19da40864..7220efe7fa 100644 --- a/integrations/api_activitypub_person_test.go +++ b/integrations/api_activitypub_person_test.go @@ -17,7 +17,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/stretchr/testify/assert" ) diff --git a/models/forgefed/branch.go b/models/forgefed/branch.go index da1b995e48..a4519e39fb 100644 --- a/models/forgefed/branch.go +++ b/models/forgefed/branch.go @@ -5,7 +5,7 @@ package forgefed import ( - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/valyala/fastjson" ) @@ -48,7 +48,7 @@ func (br *Branch) UnmarshalJSON(data []byte) error { } br.Ref = ap.JSONGetItem(val, "ref") - + return ap.OnObject(&br.Object, func(a *ap.Object) error { return ap.LoadObject(val, a) }) diff --git a/models/forgefed/commit.go b/models/forgefed/commit.go index 70b5e2621a..9c13374408 100644 --- a/models/forgefed/commit.go +++ b/models/forgefed/commit.go @@ -7,7 +7,7 @@ package forgefed import ( "time" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/valyala/fastjson" ) diff --git a/models/forgefed/forgefed.go b/models/forgefed/forgefed.go index 73767b82d9..865ddc28d5 100644 --- a/models/forgefed/forgefed.go +++ b/models/forgefed/forgefed.go @@ -5,7 +5,7 @@ package forgefed import ( - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) // GetItemByType instantiates a new ForgeFed object if the type matches diff --git a/models/forgefed/push.go b/models/forgefed/push.go index edcdf837e3..2995661249 100644 --- a/models/forgefed/push.go +++ b/models/forgefed/push.go @@ -5,7 +5,7 @@ package forgefed import ( - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/valyala/fastjson" ) diff --git a/models/forgefed/repository.go b/models/forgefed/repository.go index e85e793ae8..9777ff250e 100644 --- a/models/forgefed/repository.go +++ b/models/forgefed/repository.go @@ -5,7 +5,7 @@ package forgefed import ( - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/valyala/fastjson" ) diff --git a/models/forgefed/repository_test.go b/models/forgefed/repository_test.go index 4bf36a66ce..ff5996ab25 100644 --- a/models/forgefed/repository_test.go +++ b/models/forgefed/repository_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) func Test_GetItemByType(t *testing.T) { diff --git a/models/forgefed/ticket.go b/models/forgefed/ticket.go index fa988f5d41..5860906684 100644 --- a/models/forgefed/ticket.go +++ b/models/forgefed/ticket.go @@ -7,7 +7,7 @@ package forgefed import ( "time" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/valyala/fastjson" ) diff --git a/modules/activitypub/follow.go b/modules/activitypub/follow.go index 919b697a8f..3361ca57f8 100644 --- a/modules/activitypub/follow.go +++ b/modules/activitypub/follow.go @@ -11,7 +11,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) func Follow(ctx context.Context, activity ap.Follow) { diff --git a/modules/activitypub/repo.go b/modules/activitypub/repo.go new file mode 100644 index 0000000000..0552393045 --- /dev/null +++ b/modules/activitypub/repo.go @@ -0,0 +1,20 @@ +// Copyright 2022 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package activitypub + +import ( + "code.gitea.io/gitea/models" + repo_model "code.gitea.io/gitea/models/repo" + user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/repository" + + ap "gitea.com/Ta180m/activitypub" +) + +func FederatedRepoNew(user *user_model.User, name string, IRI ap.IRI) (*repo_model.Repository, error) { + return repository.CreateRepository(user, user, models.CreateRepoOptions{ + Name: name, + }) +} diff --git a/modules/activitypub/send.go b/modules/activitypub/send.go index ead664fd14..c41d3e1dac 100644 --- a/modules/activitypub/send.go +++ b/modules/activitypub/send.go @@ -16,7 +16,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) func Fetch(iri *url.URL) (b []byte, err error) { diff --git a/modules/activitypub/user.go b/modules/activitypub/user.go index 4b7d958b56..6104f8faa5 100644 --- a/modules/activitypub/user.go +++ b/modules/activitypub/user.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/models/auth" user_model "code.gitea.io/gitea/models/user" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) func FederatedUserNew(name string, IRI ap.IRI) error { diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 36b6d7ccfd..d277beb1ad 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -19,7 +19,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/api/v1/utils" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) // Person function returns the Person actor for a user @@ -157,10 +157,10 @@ func PersonOutbox(ctx *context.APIContext) { var activity ap.ObjectOrLink switch action.OpType { case models.ActionCreateRepo: - activity = ap.Create{Type: ap.CreateType}//, Object: forgefed.RepositoryNew()} + activity = ap.Create{Type: ap.CreateType} //, Object: forgefed.RepositoryNew()} case models.ActionRenameRepo: - activity = ap.Move{Type: ap.MoveType}//, Object: forgefed.RepositoryNew()} - // etc + activity = ap.Move{Type: ap.MoveType} //, Object: forgefed.RepositoryNew()} + // etc } outbox.OrderedItems.Append(activity) } diff --git a/routers/api/v1/activitypub/repo.go b/routers/api/v1/activitypub/repo.go index a3611776a7..4b5486fef9 100644 --- a/routers/api/v1/activitypub/repo.go +++ b/routers/api/v1/activitypub/repo.go @@ -17,7 +17,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/api/v1/utils" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" ) // Repo function diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go index ff3280d954..3d5f8f9d35 100644 --- a/routers/api/v1/activitypub/reqsignature.go +++ b/routers/api/v1/activitypub/reqsignature.go @@ -16,7 +16,7 @@ import ( gitea_context "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/go-fed/httpsig" ) diff --git a/routers/api/v1/activitypub/response.go b/routers/api/v1/activitypub/response.go index fb14653523..b0894db341 100644 --- a/routers/api/v1/activitypub/response.go +++ b/routers/api/v1/activitypub/response.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" - ap "github.com/go-ap/activitypub" + ap "gitea.com/Ta180m/activitypub" "github.com/go-ap/jsonld" )