Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Federated following, starring, issues, forks, and pull requests #20391

Closed
wants to merge 94 commits into from
Closed
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
d12fd43
Add Person and Repository ActivityPub endpoints
Jun 19, 2022
a7f32d3
Finish initial ForgeFed implementation
Jun 20, 2022
e090c95
Write a FEDERATION.md describing future Gitea federation features
Jun 21, 2022
24a462a
Delete the old example from FEDERATION.md
Jun 21, 2022
30a703c
Fix minor wording issue
Jun 22, 2022
e348477
Add some additional info about migrations to FEDERATION.md
Jun 26, 2022
786ee03
Merge remote-tracking branch 'upstream/main'
Jun 26, 2022
721b734
Merge remote-tracking branch 'upstream/main'
Jul 7, 2022
fa72294
Fix build errors and start working on constructing outbox activities …
Jul 7, 2022
18b4cd3
Don't track go.work files
Jul 7, 2022
8b354fe
Merge remote-tracking branch 'upstream/main'
Jul 10, 2022
d016dbb
Switch to using gitea.com/Ta180m/activitypub fork of the go-ap/activi…
Jul 11, 2022
79a59bd
Use a replace in go.mod to point to Ta180m/activitypub fork instead o…
Jul 11, 2022
1b39e39
Add basic implementation of federated commenting
Jul 11, 2022
63aa270
Initial implementation of federated pull requests
Jul 13, 2022
a63b2be
Merge remote-tracking branch 'upstream/main'
Jul 13, 2022
5671739
Big refactor: Improve inbox handling logic, move some IRI stuff to ir…
Jul 14, 2022
0609d71
Add more TODO notes
Jul 14, 2022
1b4cd98
Merge remote-tracking branch 'upstream/main'
Jul 14, 2022
b491a2e
Update FEDERATION.md with a more accurate description of federated is…
Jul 17, 2022
705706b
Generate person outbox for only repo creates and stars
Jul 17, 2022
f1577c2
Merge remote-tracking branch 'upstream/main'
Jul 17, 2022
48deb8e
Fix repo AP outbox path typo
Jul 17, 2022
08cb2d6
Fix typos in FEDERATION.md
Jul 17, 2022
c100b8e
Apply suggestions from code review
Jul 17, 2022
0925235
Fix federated following/unfollowing regression
Jul 20, 2022
6e10030
Merge remote-tracking branch 'upstream/main'
Jul 20, 2022
c8a8e1e
Check err in Follow() to avoid crash and don't check FederatedUserNew…
Jul 20, 2022
5196dcd
Check if httpsig keyID matches actor and attributedTo
Jul 20, 2022
85abd9c
Fix typo in follow.go
Jul 22, 2022
763f98b
Create user at /authorize_interaction?uri= endpoint
Jul 23, 2022
5da6b4f
Disable authorize_endpoint if federation is disabled
Jul 24, 2022
ab540d0
Create new federated users in reqsignature.go
Jul 24, 2022
bffb682
Fix a bunch of lint errors (still 10 more to fix 🙁)
Jul 24, 2022
30b431d
Set ap.ItemTyperFunc to correctly unmarshal JSON
Jul 25, 2022
38a687c
Replace GetID() with GetLink()
Jul 25, 2022
f0cded8
Start cleaning up fork.go
Jul 27, 2022
d909c97
Move models/forgefed to modules/forgefed
Jul 27, 2022
8e5621c
Merge remote-tracking branch 'upstream/main'
Jul 27, 2022
c94a891
Process Like activities for starring repos
Jul 27, 2022
71b2b4d
Implement FederatedRepoNew
Jul 27, 2022
fe8ef28
Merge remote-tracking branch 'upstream/main'
Aug 4, 2022
ecefb6a
Merge remote-tracking branch 'upstream/main'
Aug 10, 2022
0b97c6a
Cache remote user public keys
Aug 15, 2022
d945e6a
Start working on Ticket object endpoint implementation
Aug 15, 2022
6b73c09
Download avatar from URL and set it with user_service.UploadAvatar
Aug 15, 2022
6a6c6b3
Merge remote-tracking branch 'upstream/main'
Aug 19, 2022
27cda2f
Implement JSONLoad, To, and On functions for ForgeFed types
Aug 21, 2022
b3c065c
Refactor RepoInbox to use On functions instead of type assertions
Aug 21, 2022
18809f8
Make the frontend linter happy
Aug 22, 2022
b9dd4a2
Make revive linter happy
Aug 22, 2022
819e495
Make gofmt happy
Aug 22, 2022
1bc8e67
Fix linting errors (errcheck)
Aug 22, 2022
f1e61af
Fix another linting error
Aug 22, 2022
ee85f7d
Use the Repository AttributedTo to get owner IRI
Aug 22, 2022
c0efded
Fix typo for JSONUnmarshalerFn description comment
Aug 22, 2022
73284db
Add authorize_interaction case for Tickets
Aug 22, 2022
5ad0387
Add copyright to test file
Aug 22, 2022
2373b41
Add paginition to Person's outbox
Aug 22, 2022
45324e1
Add todo
Aug 22, 2022
2e957e7
Fix repository tests
Aug 22, 2022
ec1ffd6
Merge remote-tracking branch 'upstream/main'
anthowan Sep 5, 2022
f026988
Fix build errors
anthowan Sep 5, 2022
42b1bac
Merge remote-tracking branch 'upstream/main'
anthowan Sep 12, 2022
47229ea
Merge remote-tracking branch 'upstream/main'
anthowan Sep 15, 2022
f7dbbf7
Remove /integrations directory
anthowan Sep 15, 2022
117463b
Change Ta180m/activitypub to xy/activitypub
anthowan Sep 16, 2022
26f57be
Merge remote-tracking branch 'upstream/main'
anthowan Sep 22, 2022
379b9a7
Serve issues as ForgeFed tickets
anthowan Sep 23, 2022
f9d9019
Fix Comment permission checking
anthowan Sep 23, 2022
cbc2a97
Set isResolved to true for closed issues
anthowan Sep 29, 2022
e78dd69
Merge remote-tracking branch 'upstream/main'
anthowan Oct 18, 2022
f133e9c
Implement sending follow activities
anthowan Oct 21, 2022
5612130
Merge remote-tracking branch 'upstream/main'
anthowan Oct 27, 2022
69c1bdd
Merge remote-tracking branch 'upstream/main'
anthowan Nov 8, 2022
0cacdc3
More Ticket IRI processing to iri.go
anthowan Nov 11, 2022
f75ab80
make fmt
anthowan Nov 11, 2022
ca50224
Send out undo follow activity in UnfollowUser
anthowan Nov 12, 2022
20e8c64
Fix UnfollowUser addressing
anthowan Nov 12, 2022
19af0c9
Implement loading remote tickets
anthowan Nov 25, 2022
d22dab7
Add custom NotEmpty function to handle ForgeFed types
anthowan Nov 26, 2022
447650f
Remove @ from regex because idk what it was doing there in the first …
anthowan Nov 26, 2022
41e9a10
make fmt
anthowan Nov 26, 2022
fd4d0e7
Move AS object processing to routers/api/v1/activitypub, move AP tran…
anthowan Nov 27, 2022
2d74e4f
Delete fork code and move createPullRequest to create.go
anthowan Nov 27, 2022
c982b67
Set issue Index, not ID, when creating issues from an AS object
anthowan Nov 27, 2022
a666eef
Rewrite createPullRequest and add createPersonFromIRI
anthowan Nov 27, 2022
3f5f626
Fix AppSubURL -> AppURL typo
anthowan Nov 27, 2022
1066cfe
Implement commenting and fix lint errors
anthowan Nov 27, 2022
77896f1
Save issue IRIs when creating them from AS objects
anthowan Nov 27, 2022
3e690fb
Federated issue creation
anthowan Nov 27, 2022
f5a50ce
Add Note object endpoint
anthowan Nov 27, 2022
c64d3fa
Implement commenting on issues from Mastodon
anthowan Nov 27, 2022
439f675
Don't send emails to federated users
anthowan Nov 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions FEDERATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Federation

*This describes Gitea's future federation capabilities, not what it can do currently.*

Gitea is federated using [ActivityPub](https://www.w3.org/TR/activitypub/) and the [ForgeFed extension](https://forgefed.org/) so you can interact with users and repositories from other instances as if they were on your own instance. By using the standardized ActivityPub protocol, users on any fediverse software such as [Mastodon](https://joinmastodon.org/) can follow Gitea users, star repositories, receive activity updates, and comment on issues.

C2S ActivityPub is not supported because Gitea already has an existing API.

## Following

You can use any fediverse software to follow a Gitea user. Gitea will automatically accept follow requests. The usernames of remote users are displayed as `username@instance.com`. To follow a remote user, click follow on their profile page, and a pop-up box will appear for you to type in your instance. You are redirected to your own instance, where the remote user is fetched and rendered, and you can now follow them.

When following a Gitea user, you will receive updates when they star a repo, create, fork, or make a private repo public, or follow a user. If you are using Mastodon or Pleroma, these will show up in your feed.

## Starring

You can star repositories on another instance. The full name of a remote repository is `username@instance.com/reponame`. Similar to following, a pop-up box appears for you to type in your instance, and you are redirected to your own instance, where the remote repository is fetched and rendered.

## Organizations

You can add users from other instances to organizations. An organization has a name and an instance, so its full name would look like `orgname@instance.com`. This indicates that the organization data resides on `instance.com`. To prevent synchronization errors, this data is only synchronized one-way to other instances.

## Collaborators

You can add users from other instances as collaborators. As mentioned previously, a repository has full name `username@instance.com/reponame`, which indicates that the repository data resides on `instance.com`. Each collaborator's instance has a copy of the repository, but to prevent synchronization errors, the copy at `instance.com` is the main copy and it is synchronized one-way to all other instances. When a collaborator tries to modify their copy of the repository, the modification is first sent to the main copy at `instance.com` and then synchronized back to their instance.

## Issues

You can create an issue on a remote repository. Your instance can also render a remote issue that you created so you can edit it or comment on it.

## Forks

When forking a remote repository, the fork is created on your instance, not the remote instance.

## Pull requests

When opening a pull request to a remote repository, the pull request can be rendered on your instance. Federated pull requests use the AGit-flow.

## Comments

You can comment on an issue or pull request using any fediverse software. The issue and existing comments are rendered on your instance.

## Migrations

If you change your username or the name of a repository, Gitea handles this similarly to how Mastodon does. Gitea will send a `Move` activity to your followers and update your actor to point to the new actor and the new actor to point to the old actor.

Changing your instance or a repository's instance is handled in a similar way, but additionally, the data to be migrated between instances.
2 changes: 1 addition & 1 deletion custom/conf/app.example.ini
Original file line number Diff line number Diff line change
@@ -2308,7 +2308,7 @@ ROUTER = console
;SHARE_USER_STATISTICS = true
;;
;; Maximum federation request and response size (MB)
;MAX_SIZE = 4
;MAX_SIZE = 8
;;
;; WARNING: Changing the settings below can break federation.
;;
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ require (
github.com/fsnotify/fsnotify v1.5.4
github.com/gliderlabs/ssh v0.3.5
github.com/go-ap/activitypub v0.0.0-20220917143152-e4e7018838c0
github.com/go-ap/jsonld v0.0.0-20220917142617-76bf51585778
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
github.com/go-chi/chi/v5 v5.0.7
github.com/go-chi/cors v1.2.1
github.com/go-enry/go-enry/v2 v2.8.3
@@ -87,6 +87,7 @@ require (
github.com/tstranex/u2f v1.0.0
github.com/unrolled/render v1.5.0
github.com/urfave/cli v1.22.10
github.com/valyala/fastjson v1.6.3
github.com/xanzy/go-gitlab v0.73.1
github.com/yohcop/openid-go v1.0.0
github.com/yuin/goldmark v1.5.2
@@ -168,7 +169,7 @@ require (
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // 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-20220917143055-4283ea5dae18 // indirect
github.com/go-ap/errors v0.0.0-20221115052505-8aaa26f930b4 // 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
@@ -264,7 +265,6 @@ require (
github.com/toqueteos/webbrowser v1.2.0 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/unknwon/com v1.0.1 // indirect
github.com/valyala/fastjson v1.6.3 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xanzy/ssh-agent v0.3.2 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
@@ -302,6 +302,8 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142

replace github.com/satori/go.uuid v1.2.0 => github.com/gofrs/uuid v4.2.0+incompatible

replace github.com/go-ap/activitypub => gitea.com/xy/activitypub v0.0.0-20221126171442-81405e14ea3b

exclude github.com/gofrs/uuid v3.2.0+incompatible

exclude github.com/gofrs/uuid v4.0.0+incompatible
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -96,6 +96,8 @@ gitea.com/lunny/levelqueue v0.4.2-0.20220729054728-f020868cc2f7 h1:Zc3RQWC2xOVgl
gitea.com/lunny/levelqueue v0.4.2-0.20220729054728-f020868cc2f7/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
gitea.com/xy/activitypub v0.0.0-20221126171442-81405e14ea3b h1:z5zmwZVoKEu2c3+lGiLlTDxQZpcKlZoWz4wjCtcyfxU=
gitea.com/xy/activitypub v0.0.0-20221126171442-81405e14ea3b/go.mod h1:1jG7QyKCGx/FO63p/xWO0h9ytVSJmkjcQSYPj6zWpGs=
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121 h1:r3qt8PCHnfjOv9PN3H+XXKmDA1dfFMIN1AislhlA/ps=
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121/go.mod h1:Ock8XgA7pvULhIaHGAk/cDnRfNrF9Jey81nPcc403iU=
@@ -471,12 +473,10 @@ github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
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-20220917143152-e4e7018838c0 h1:EUMB0x7u3de/ikGBtXiLxaJbmxgiqiAcM4yjW4whApM=
github.com/go-ap/activitypub v0.0.0-20220917143152-e4e7018838c0/go.mod h1:OX9ajs2vU4UauC/DlghS/8M468Kn79r+y9kB6j7LuGM=
github.com/go-ap/errors v0.0.0-20220917143055-4283ea5dae18 h1:A48SbkWKEciiJMbbcPzaRj9aizPUABzXFvCM3LtGGf8=
github.com/go-ap/errors v0.0.0-20220917143055-4283ea5dae18/go.mod h1:dd3ZgjjloBsKPDpqA2kf2VWhF0A1eKUItOBh0/QcDWI=
github.com/go-ap/jsonld v0.0.0-20220917142617-76bf51585778 h1:0tV3i8tE1NghMC4rXZXfD39KUbkKgIyLTsvOEmMOPCQ=
github.com/go-ap/jsonld v0.0.0-20220917142617-76bf51585778/go.mod h1:jyveZeGw5LaADntW+UEsMjl3IlIwk+DxlYNsbofQkGA=
github.com/go-ap/errors v0.0.0-20221115052505-8aaa26f930b4 h1:oySiT87Q2cd0o5O8er2zyjiRcTQA0KuOgw1N9+RQqG0=
github.com/go-ap/errors v0.0.0-20221115052505-8aaa26f930b4/go.mod h1:SaTNjEEkp0q+w3pUS1ccyEL/lUrHteORlDq/e21mCc8=
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73 h1:GMKIYXyXPGIp+hYiWOhfqK4A023HdgisDT4YGgf99mw=
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73/go.mod h1:jyveZeGw5LaADntW+UEsMjl3IlIwk+DxlYNsbofQkGA=
github.com/go-asn1-ber/asn1-ber v1.5.4 h1:vXT6d/FNDiELJnLb6hGNa309LMsrCoYFvpwHDF0+Y1A=
github.com/go-asn1-ber/asn1-ber v1.5.4/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-chi/chi/v5 v5.0.1/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
21 changes: 13 additions & 8 deletions models/activities/action.go
Original file line number Diff line number Diff line change
@@ -329,14 +329,15 @@ func (a *Action) GetIssueContent() string {
// GetFeedsOptions options for retrieving feeds
type GetFeedsOptions struct {
db.ListOptions
RequestedUser *user_model.User // the user we want activity for
RequestedTeam *organization.Team // the team we want activity for
RequestedRepo *repo_model.Repository // the repo we want activity for
Actor *user_model.User // the user viewing the activity
IncludePrivate bool // include private actions
OnlyPerformedBy bool // only actions performed by requested user
IncludeDeleted bool // include deleted actions
Date string // the day we want activity for: YYYY-MM-DD
RequestedUser *user_model.User // the user we want activity for
RequestedTeam *organization.Team // the team we want activity for
RequestedRepo *repo_model.Repository // the repo we want activity for
RequestedActionType ActionType // the type of activity we want
Actor *user_model.User // the user viewing the activity
IncludePrivate bool // include private actions
OnlyPerformedBy bool // only actions performed by requested user
IncludeDeleted bool // include deleted actions
Date string // the day we want activity for: YYYY-MM-DD
}

// GetFeeds returns actions according to the provided options
@@ -448,6 +449,10 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
}
}

if opts.RequestedActionType != 0 {
cond = cond.And(builder.Eq{"`action`.op_type": opts.RequestedActionType})
}

return cond, nil
}

4 changes: 2 additions & 2 deletions models/activities/action_test.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (

activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/models/db"
issue_model "code.gitea.io/gitea/models/issues"
issues_model "code.gitea.io/gitea/models/issues"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -31,7 +31,7 @@ func TestAction_GetRepoLink(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
comment := unittest.AssertExistsAndLoadBean(t, &issue_model.Comment{ID: 2})
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2})
action := &activities_model.Action{RepoID: repo.ID, CommentID: comment.ID}
setting.AppSubURL = "/suburl"
expected := path.Join(setting.AppSubURL, owner.Name, repo.Name)
22 changes: 14 additions & 8 deletions models/auth/source.go
Original file line number Diff line number Diff line change
@@ -23,14 +23,15 @@ type Type int

// Note: new type must append to the end of list to maintain compatibility.
const (
NoType Type = iota
Plain // 1
LDAP // 2
SMTP // 3
PAM // 4
DLDAP // 5
OAuth2 // 6
SSPI // 7
NoType Type = iota
Plain // 1
LDAP // 2
SMTP // 3
PAM // 4
DLDAP // 5
OAuth2 // 6
SSPI // 7
Federated // 8
)

// String returns the string name of the LoginType
@@ -179,6 +180,11 @@ func (source *Source) IsSSPI() bool {
return source.Type == SSPI
}

// IsFederated returns true of this source is of the Federated type.
func (source *Source) IsFederated() bool {
return source.Type == Federated
}

// HasTLS returns true of this source supports TLS.
func (source *Source) HasTLS() bool {
hasTLSer, ok := source.Cfg.(HasTLSer)
16 changes: 16 additions & 0 deletions models/issues/comment.go
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import (
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/references"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
@@ -1549,3 +1550,18 @@ func FixCommentTypeLabelWithOutsideLabels() (int64, error) {

return res.RowsAffected()
}

func (c *Comment) GetIRI() string {
err := c.LoadIssue()
if err != nil {
return ""
}
err = c.Issue.LoadRepo(db.DefaultContext)
if err != nil {
return ""
}
if strings.Contains(c.Issue.Repo.OwnerName, "@") {
return c.OldTitle
}
return setting.AppURL + "api/v1/activitypub/note/" + c.Issue.Repo.OwnerName + "/" + c.Issue.Repo.Name + "/" + strconv.FormatInt(c.Issue.Index, 10) + "/" + strconv.FormatInt(c.ID, 10)
}
12 changes: 12 additions & 0 deletions models/issues/issue.go
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/references"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
@@ -2471,3 +2472,14 @@ func DeleteOrphanedIssues() error {
}
return nil
}

func (issue *Issue) GetIRI() string {
err := issue.LoadRepo(db.DefaultContext)
if err != nil {
log.Error(fmt.Sprintf("loadRepo: %v", err))
}
if strings.Contains(issue.Repo.OwnerName, "@") {
return issue.OriginalAuthor
}
return setting.AppURL + "api/v1/activitypub/ticket/" + issue.Repo.OwnerName + "/" + issue.Repo.Name + "/" + strconv.FormatInt(issue.Index, 10)
}
7 changes: 7 additions & 0 deletions models/repo/repo.go
Original file line number Diff line number Diff line change
@@ -802,3 +802,10 @@ func FixNullArchivedRepository() (int64, error) {
IsArchived: false,
})
}

func (r *Repository) GetIRI() string {
if strings.Contains(r.OwnerName, "@") {
return r.OriginalURL
}
return setting.AppURL + "api/v1/activitypub/repo/" + r.OwnerName + "/" + r.Name
}
9 changes: 9 additions & 0 deletions models/user/avatar.go
Original file line number Diff line number Diff line change
@@ -105,6 +105,15 @@ func (u *User) AvatarLink() string {
return link
}

// AvatarFullLinkWithSize returns the full avatar link with size and http host
func (u *User) AvatarFullLinkWithSize(size int) string {
link := u.AvatarLinkWithSize(size)
if !strings.HasPrefix(link, "//") && !strings.Contains(link, "://") {
return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL+"/")
}
return link
}

// IsUploadAvatarChanged returns true if the current user's avatar would be changed with the provided data
func (u *User) IsUploadAvatarChanged(data []byte) bool {
if !u.UseCustomAvatar || len(u.Avatar) == 0 {
7 changes: 7 additions & 0 deletions models/user/user.go
Original file line number Diff line number Diff line change
@@ -1339,3 +1339,10 @@ func GetOrderByName() string {
}
return "name"
}

func (u *User) GetIRI() string {
if u.LoginType == auth.Federated {
return u.LoginName
}
return setting.AppURL + "api/v1/activitypub/user/" + u.Name
}
Loading