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

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

wants to merge 94 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 17, 2022

EDIT: I'm now working on federation for Forgejo, and after it is merged in Forgejo, I will create a new PR to upstream federation to Gitea.

This (very WIP) pull request implements the federated features of following, starring, issues, forks, and pull requests. 🎉

Much of the code is still incomplete, but I wanted to create the PR now since I'd like to get some feedback on some of the high-level design decisions here, such as the UI, or how remote users and repos are handled.

Remote users

This PR stores remote users in the database using the new LoginType Federated, with the full username@instance.com as the username.

More information: #2

Closes #9045

Following

See #19981

ForgeFed vocabulary implementation

This PR includes an implementation of the ForgeFed vocabulary using a custom fork of go-ap. The fork exports more helper functions to make it easier to add AP extensions to go-ap. Discussion about this can be found on the go-ap mailing lists.

Issues and comments

I haven't written the implementation for federated issues yet, but it should be relatively easy. Federated commenting works, but Gitea<->Mastodon interoperability is tricky. There is currently an issue in Mastodon that prevents Mastodon users from commenting on Gitea issues. Also, Mastodon has threads and Gitea doesn't.

Forks and pull requests

TODO, since the code will be rewritten to use the AGit flow for handling federated pull requests.

More information: #7

Closes #184, closes #15392

Federation.md

A Federation.md file describes how a certain software uses ActivityPub. This PR's FEDERATION.md describes Gitea's future federation capabilities, not what features that this PR adds to Gitea.

UI

I'm working on a UI right now, see #8. Since the UI is far from finished, for now I'm hand-writing ActivityStreams objects and then POSTing them to the inbox API endpoints with the help of some scripts.

Limitations

This PR only implements a few federated features to prevent the PR from getting too big. For a list of features that will be implemented later but not in this PR, see the task list.

TODO

  • Properly cache remote user avatar and public key
  • Fix problems with extending go-ap
  • Serve issues and pull requests as ForgeFed objects at /api/v1/activitypub/ticket/username/reponame/number.
  • Finish starring, issues, and pull requests implementations
  • Implement issue, PR, or comment state changes (https://codeberg.org/ForgeFed/ForgeFed/issues/98)
  • Finish /authorize_interaction?uri= implementation
  • Create redirect UI for redirecting from a remote instance to your instance
  • Use AGit flow for federated PRs to save disk space
  • Send out activities to followers when starring or creating a repo
  • Fix lint errors
  • Write integration tests

Anthony Wang and others added 22 commits June 19, 2022 10:39
…typub module since we need more Write and Load functions exported
@ghost ghost marked this pull request as draft July 17, 2022 02:04
Copy link
Contributor

@Gusted Gusted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be me, but we might also implement the prevention of impersonation(AttributedTo still seems to be not checked)

FEDERATION.md Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
models/db/name.go Outdated Show resolved Hide resolved
models/forgefed/branch.go Outdated Show resolved Hide resolved
models/forgefed/branch.go Outdated Show resolved Hide resolved
routers/api/v1/activitypub/person.go Show resolved Hide resolved
routers/api/v1/activitypub/person.go Outdated Show resolved Hide resolved
routers/api/v1/activitypub/person.go Outdated Show resolved Hide resolved
routers/web/user/profile.go Outdated Show resolved Hide resolved
Actor: ctx.ContextUser,
IncludePrivate: false,
IncludeDeleted: false,
ListOptions: db.ListOptions{Page: 1, PageSize: 1000000},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh for performance reasons we likely want to not do this(Increased pagesize is fine), does AP supports list/pages options like this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AP does support pagination, but the problem is we only want the repo creation actions, but we don't know how many pages of the DB we'll have to query for. Is there a way we can make models.GetFeeds only return repo creation actions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2373b41 is the right direction but we need to implement star action types in another PR so we can remove the stars code.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 17, 2022
FEDERATION.md Outdated Show resolved Hide resolved
FEDERATION.md Outdated Show resolved Hide resolved
FEDERATION.md Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Jul 17, 2022

Might be me, but we might also implement the prevention of impersonation(AttributedTo still seems to be not checked)

Thanks for reminding me to implement that. I'll do it today.

@lunny lunny modified the milestones: 1.18.0, 1.19.0 Oct 17, 2022
@ghost ghost closed this Nov 27, 2022
@lunny lunny removed this from the 1.19.0 milestone Feb 22, 2023
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/federation type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
6 participants