Commit graph

4509 commits

Author SHA1 Message Date
Michael Jerger
28a290da10 reviewed current work 2024-02-10 15:10:13 +01:00
erik
d27cac5bae Move federated user creation to func 2024-02-10 15:10:11 +01:00
erik
01506f9836 Clearer description 2024-02-10 15:10:11 +01:00
erik
77b6402e77 Add missing error treatment 2024-02-10 15:10:10 +01:00
erik
946e5cf34c Remove typo in func 2024-02-10 15:10:10 +01:00
erik
2fb893843b Move getting person to own function 2024-02-10 15:10:08 +01:00
erik
6d143e74cf More clear distinction between sender and receiver of star 2024-02-10 15:10:07 +01:00
Michael Jerger
9b5d8bbeda If we use user.loginname to store the actor.id we can search for local users earlier 2024-02-10 15:10:04 +01:00
erik
ed1af14ceb Panic on error, use correct function names 2024-02-10 15:10:04 +01:00
erik
9dcbe0177e Rename targe to remoteStargazer 2024-02-10 15:10:03 +01:00
erik
de9e4dea61 Update todos, remove comments 2024-02-10 15:10:02 +01:00
erik
68cc74d139 Use actionsUser for creating http client 2024-02-10 15:10:01 +01:00
erik
d65e5aa70e Move helper functions to top 2024-02-10 15:10:00 +01:00
Mirco
1c145d9d68 WIP: fit generateUUIDMail for testing purposes 2024-02-10 15:10:00 +01:00
Mirco
11e93784fe WIP: log Info User created 2024-02-10 15:09:59 +01:00
Mirco
a20f535211 WIP: pwdgen, username 2024-02-10 15:09:58 +01:00
erik
85e09a7ada WIP: Generate User if not exists 2024-02-10 15:09:58 +01:00
Michael Jerger
94880d64f4 higlight the need for id normalization 2024-02-10 15:09:57 +01:00
Michael Jerger
231bdb65b8 searching for the local person 2024-02-10 15:09:57 +01:00
erik
edd7fb77fd WIP create user if not exists 2024-02-10 15:09:56 +01:00
erik
41e12d09ef WIP create User from person 2024-02-10 15:09:55 +01:00
erik
c8456d57ff Add thoughts on user creation 2024-02-10 15:09:54 +01:00
erik
22ba03ae4d Don't use redundant implementation of person 2024-02-10 15:09:51 +01:00
erik
a8d5e7ba77 Fix typos and format 2024-02-10 15:09:41 +01:00
erik
d43c4ba739 Use person generation 2024-02-10 15:09:38 +01:00
erik
9f016d3673 Move to extra var 2024-02-10 15:09:37 +01:00
erik
fde8de4f90 Rename to ParseActorIDFromStarActivity 2024-02-10 15:09:35 +01:00
erik
e60d89cb67 Use correct target for get request 2024-02-10 15:09:33 +01:00
erik
0388240039 WIP Use non generated HTTP client 2024-02-10 15:09:32 +01:00
erik
6284355e1e Remove redundant ValidateStar and err check, call coorect function 2024-02-10 15:09:29 +01:00
erik
546ce50337 Use PanicIfInvalid in repository.go 2024-02-10 15:09:27 +01:00
erik
8300d3fbde Add ToDos from code review 2024-02-10 15:09:25 +01:00
erik
34c511ae98 Use data from actor, improve formatting 2024-02-10 15:09:24 +01:00
erik
aee2ee2596 Also log error on person creation 2024-02-10 15:09:24 +01:00
erik
3d2b5115ad Implement and use Validatable interface 2024-02-10 15:09:18 +01:00
erik
235ed7cd1e Rename to actorID 2024-02-10 15:09:18 +01:00
Michael Jerger
5e111f14ef use the swagger-api 2024-02-10 15:09:17 +01:00
Michael Jerger
5c998a5c46 add comment 2024-02-10 15:09:08 +01:00
erik
5729cee3e5 Move test to model/activitypub 2024-02-10 15:09:07 +01:00
erik
7193c0bd9b WIP test for parsing the actor 2024-02-10 15:09:07 +01:00
erik
0c367070af Call validate star 2024-02-10 15:09:06 +01:00
erik
78fc75135f Rename to ActorData 2024-02-10 15:09:04 +01:00
erik
91dcd59e68 Import parser from model and call validation 2024-02-10 15:09:00 +01:00
erik
e44321221e WIP: Add test for parser 2024-02-10 15:08:55 +01:00
erik
ad65976677 Reorder functions 2024-02-10 15:08:54 +01:00
erik
d52bb4bf8f Remove newline from error string 2024-02-10 15:08:52 +01:00
erik
b869d91dc1 Parse Actor URL 2024-02-10 15:08:51 +01:00
erik
9fa8d19cf4 Fix typo 2024-02-10 15:08:47 +01:00
Michael Jerger
d10c1094d9 add some pseudocode 2024-02-10 15:08:45 +01:00
erik
ab92891091 Use actor 2024-02-10 15:08:41 +01:00
erik
b085ce37a6 Review 2024-02-10 15:08:40 +01:00
erik
d7abff31f6 Add ToDos 2024-02-10 15:08:36 +01:00
erik
f48b4d1f55 Get Activity field from star 2024-02-10 15:08:29 +01:00
Michael Jerger
1044e44ee5 we got a parsed actor 2024-02-10 15:08:12 +01:00
Michael Jerger
b08580280a np in case of unauthenticated user 2024-02-10 15:08:10 +01:00
Michael Jerger
460e2fb644 prepare next steps 2024-02-10 15:08:00 +01:00
erik
5b01517c12 Get data from form 2024-02-10 15:08:00 +01:00
Michael Jerger
dc1a82bf4c use star as swagger model 2024-02-10 15:07:48 +01:00
Michael Jerger
46fb4fec8f add star activity & bind to swagger 2024-02-10 15:07:40 +01:00
Michael Jerger
ff5a4405fd introduce repo from exosy 2024-02-10 15:07:39 +01:00
Michael Jerger
7195141805 wip: lets define the post input more close 2024-02-10 15:07:29 +01:00
Michael Jerger
6587b6d62b log who is doing the inbox post 2024-02-10 15:07:28 +01:00
Michael Jerger
4e1e65e14f log repository under activity 2024-02-10 15:07:26 +01:00
Michael Jerger
fe6f625923 temp deactivate security 2024-02-10 15:07:25 +01:00
Michael Jerger
87324d1553 ctx action should no be good enough 2024-02-10 15:07:22 +01:00
Michael Jerger
0d5702e501 fill in some minimal information to an actor 2024-02-10 15:07:20 +01:00
Michael Jerger
fe2a3d86d4 get repo now works somehow 2024-02-10 15:07:14 +01:00
Michael Jerger
64abf87fb0 added some logs 2024-02-10 15:07:11 +01:00
Mirco
511ab65df4 Fix syntax error, unexpected new line 2024-02-10 15:07:07 +01:00
Michael Jerger
154be0a637 wip: compile one step further 2024-02-10 15:07:06 +01:00
Michael Jerger
317b7fac8f wip: load repo to ctx 2024-02-10 15:07:05 +01:00
Michael Jerger
d4f507a223 remove unused imports 2024-02-10 15:07:04 +01:00
Michael Jerger
a87cbda165 add repository actor 2024-02-10 15:07:03 +01:00
Earl Warren
7cbf05fafb
Merge remote-tracking branch 'forgejo/forgejo-dependency' into wip-forgejo
Conflicts:
	.forgejo/workflows/testing.yml
	trivial conflict
2024-02-09 19:00:54 +01:00
Caesar Schinas
271db6ff22
[FEAT] support .forgejo dir for issue and PR templates 2024-02-06 10:22:32 +01:00
Gergely Nagy
be8d16438a
Fix /api/v1/{owner}/{repo}/issue_templates
When issue templates were moved into services in
def4956122, the code was also refactored
and simplified. Unfortunately, that simplification broke the
`/api/v1/{owner}/{repo}/issue_templates` route, because it was
previously using a helper function that ignored invalid templates, and
after the refactor, the function it called *always* returned non-nil as
the second return value. This, in turn, results in the aforementioned
end point always returning an internal server error.

This change restores the previous behaviour of ignoring invalid files
returned by `issue.GetTemplatesFromDefaultBranch`, and adds a few test
cases to exercise the endpoint.

Other users of `GetTemplatesFromDefaultBranch` already ignore the second
return value, or handle it correctly, so no changes are necessary there.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-02-05 20:58:41 +01:00
Earl Warren
094c84ed6d
Merge branch 'rebase-forgejo-dependency' into wip-forgejo 2024-02-05 18:58:23 +01:00
Earl Warren
d7e1854884
Merge branch 'rebase-forgejo-branding' into wip-forgejo 2024-02-05 18:58:18 +01:00
Earl Warren
ee5a3a6401
[MODERATION] User blocking (squash) RemoveUsernameParameterSuffix 2024-02-05 17:06:02 +01:00
Earl Warren
030cdd6ae2
[GITEA] Allow changing the email address before activation (squash)
See https://codeberg.org/forgejo/forgejo/pulls/2300
2024-02-05 16:57:58 +01:00
oliverpool
ecfc3cb3f0
[GITEA] always load outdated comments
(cherry picked from commit 2615dea9af)
2024-02-05 16:57:58 +01:00
Earl Warren
49b51cbdd7
Revert "Do not render empty comments (#29039)"
This reverts commit b4513f48ce.
2024-02-05 16:57:58 +01:00
Gergely Nagy
c335d076aa
[GITEA] admin: "Self Check" should only show for some db types
The "Self Check" menu essentially runs the collation check that is also
performed at startup, and displays the results. This is only a thing for
MariaDB/MySQL and MSSQL. As such, the menu item should only be available
for these database types.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 0ca118fdc3)
2024-02-05 16:57:56 +01:00
Gergely Nagy
2ca4862f8b
[GITEA] Allow changing the repo Wiki branch to main
Previously, the repo wiki was hardcoded to use `master` as its branch,
this change makes it possible to use `main` (or something else, governed
by `[repository].DEFAULT_BRANCH`, a setting that already exists and
defaults to `main`).

The way it is done is that a new column is added to the `repository`
table: `wiki_branch`. The migration will make existing repositories
default to `master`, for compatibility's sake, even if they don't have a
Wiki (because it's easier to do that). Newly created repositories will
default to `[repository].DEFAULT_BRANCH` instead.

The Wiki service was updated to use the branch name stored in the
database, and fall back to the default if it is empty.

Old repositories with Wikis using the older `master` branch will have
the option to do a one-time transition to `main`, available via the
repository settings in the "Danger Zone". This option will only be
available for repositories that have the internal wiki enabled, it is
not empty, and the wiki branch is not `[repository].DEFAULT_BRANCH`.

When migrating a repository with a Wiki, Forgejo will use the same
branch name for the wiki as the source repository did. If that's not the
same as the default, the option to normalize it will be available after
the migration's done.

Additionally, the `/api/v1/{owner}/{repo}` endpoint was updated: it will
now include the wiki branch name in `GET` requests, and allow changing
the wiki branch via `PATCH`.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit d87c526d2a)
2024-02-05 16:57:47 +01:00
Gusted
464ae81a36
[GITEA] Refactor generation of JWT secret
- Remove non base64-ed version of JWT secret generation. Because all
occurences need the Base64 version.

(cherry picked from commit 6a6b5a31a8)
(cherry picked from commit 066b8ca6b4)
2024-02-05 16:54:44 +01:00
Gusted
c831ff67e4
[GITEA] Simplify blame handler
- Remove unnecessary checks for `ctx.Repo.TreePath`, because it will
already early-return if it's empty.
- Simplify `performBlame` to extract the repoPath from the context.
- Don't render the topics, as they are not shown in the blame
page (there's a condition in the template for the blame page).
- Fix that `performBlame` doesn't call `NotFound`, it should instead
only return the error.
- Fix that the error handlings call `ServerError` instead of `NotFound`.
- Simplify `bypass-blame-ignore` to use `ctx.FormBool`.
- Remove `TreeLink`, `HasParentPath` and `ParentPath` as it's not used
in the blame template.
- Inline `BranchLink` and `RawFileLink` string operations.
- Move around `NumLines` to make it clear the error is handled.
- Less code, less things the code does, more readable and thus more
maintanable!

(cherry picked from commit e02baca55c)
(cherry picked from commit 74e00620ca)
2024-02-05 16:54:44 +01:00
Earl Warren
fe8622dae3
Revert "Fix schedule tasks bugs (#28691)"
This reverts commit 97292da960.

(cherry picked from commit 83e5eba031)
(cherry picked from commit f6ef8f3819)

Conflicts:
	services/repository/setting.go
2024-02-05 16:54:42 +01:00
Earl Warren
f7fd1c7c86
Revert "Fix an actions schedule bug (#28942)"
This reverts commit adc3598a75.
2024-02-05 16:53:39 +01:00
Gergely Nagy
d4396acf82
[GITEA] Don't consider orphan branches as recently pushed
When displaying the recently pushed branches banner, don't display
branches that have no common history with the default branch. These
branches are usually not meant to be merged, so the banner is just noise
in this case.

Refs: https://codeberg.org/forgejo/forgejo/pulls/2196

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit e1fba517f4)
(cherry picked from commit 2d3c81d4f2)
(cherry picked from commit 624a61b3b8)
2024-02-05 16:09:43 +01:00
voltagex
578ab6a3c9
[GITEA] API comment update routers/api/v1/shared/runners.go
Refs: https://codeberg.org/forgejo/forgejo/pulls/2191

(cherry picked from commit 1e89dd95b9)
(cherry picked from commit fecc14a16c)
(cherry picked from commit b4509aa4c7)
(cherry picked from commit 6fdf3b2ad1)
2024-02-05 16:09:43 +01:00
Gusted
938a450c9e
[GITEA] Document correct status code for creating Tag
- When there's a succesful POST operation, it should return a 201 status
code (which is the status code for succesful created) and additionally
the created object.
- Currently for the `POST /repos/{owner}/{repo}/tags` endpoint an 200
status code was documented in the OpenAPI specification, while an 201
status code was actually being returned. In this case the code is
correct and the documented status code needs to be adjusted.
- Resolves #2200

(cherry picked from commit a2939116f5)
(cherry picked from commit 22cff41585)
(cherry picked from commit b23a7f27bb)
2024-02-05 16:09:43 +01:00
Gergely Nagy
bc7e448d49
[GITEA] Rework when recently pushed branches are displayed
With this change, the "You pushed on branch xyz" banner will be
displayed when either the viewed repository or its base repo (if the
current one's a fork) has pull requests enabled. Previously it only
displayed if the viewed repo had PRs enabled.

Furthermore, if the viewed repository is an original repository that the
viewing user has a fork of, if the forked repository has recently pushed
branches, then the banner will appear for the original repository too.
In this case, the notification will include branches from the viewing
user's fork, and branches they pushed to the base repo, too.

Refs: https://codeberg.org/forgejo/forgejo/pulls/2195

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit a29f10661d)
(cherry picked from commit 70c5e2021d)
(cherry picked from commit 48b25be67a)
2024-02-05 16:09:43 +01:00
Gusted
b020ded391
[GITEA] Adjust name of operation
- The name could be conflucted with the `GET
/user/applications/oauth2/{id}` operation, as it only differed in a
single letter being uppercase. Change it to be
userGetOAuth2Application**s**, as that's also more accurate for this function.
- Resolves #2163

(cherry picked from commit 1891dac547)
(cherry picked from commit 68fceb9b7a)
(cherry picked from commit 7335d6de54)
2024-02-05 16:09:43 +01:00
Gusted
bbe5a881cc
[GITEA] Fix API inconsistencies
- Document the correct content types for Git archives. Add code that
actually sets the correct application type for `.zip` and `.tar.gz`.
- When an action (POST/PUT/DELETE method) was successful, an 204 status
code should be returned instead of status code 200.
- Add and adjust integration testing.
- Resolves #2180
- Resolves #2181

(cherry picked from commit 6c8c4512b5)
(cherry picked from commit 3f74bcb14d)
(cherry picked from commit 6ed9057fd7)
2024-02-05 16:09:43 +01:00
Earl Warren
0b503e5e86
[GITEA] DELETE /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}
* reuse deleteIssueComment by adding the commentType parameter
* ensure tests start with a PR with no random reviews from fixtures

Refs: https://codeberg.org/forgejo/forgejo/issues/2109
(cherry picked from commit 5b90ab77f6)
(cherry picked from commit 28ecd6f5a6)
(cherry picked from commit 24870cf133)
2024-02-05 16:09:43 +01:00
Earl Warren
bd1cea3f82
[GITEA] GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}
Refs: https://codeberg.org/forgejo/forgejo/issues/2109
(cherry picked from commit 69fcf26dee)
(cherry picked from commit 1296f4d115)
(cherry picked from commit 119d10d9e2)
(cherry picked from commit eb5b55b1b7)
2024-02-05 16:09:43 +01:00
Earl Warren
e658a6a9cd
[GITEA] API commentAssignment() to verify the id belongs
Instead of repeating the tests that verify the ID of a comment
is related to the repository of the API endpoint, add the middleware
function commentAssignment() to assign ctx.Comment if the ID of the
comment is verified to be related to the repository.

There already are integration tests for cases of potential unrelated
comment IDs that cover some of the modified endpoints which covers the
commentAssignment() function logic.

* TestAPICommentReactions - GetIssueCommentReactions
* TestAPICommentReactions - PostIssueCommentReaction
* TestAPICommentReactions - DeleteIssueCommentReaction
* TestAPIEditComment - EditIssueComment
* TestAPIDeleteComment - DeleteIssueComment
* TestAPIGetCommentAttachment - GetIssueCommentAttachment

The other modified endpoints do not have tests to verify cases of
potential unrelated comment IDs. They no longer need to because they
no longer implement the logic to enforce this. They however all have
integration tests that verify the commentAssignment() they now rely on
does not introduce a regression.

* TestAPIGetComment - GetIssueComment
* TestAPIListCommentAttachments - ListIssueCommentAttachments
* TestAPICreateCommentAttachment - CreateIssueCommentAttachment
* TestAPIEditCommentAttachment - EditIssueCommentAttachment
* TestAPIDeleteCommentAttachment - DeleteIssueCommentAttachment

(cherry picked from commit d414376d74)
(cherry picked from commit 09db07aeae)
(cherry picked from commit f44830c3cb)

Conflicts:
	modules/context/api.go
	https://codeberg.org/forgejo/forgejo/pulls/2249
(cherry picked from commit 9d1bf7be15)
2024-02-05 16:09:43 +01:00
Gusted
2cfcd266b4
[GITEA] Fix panic in canSoftDeleteContentHistory
- It's possible that `canSoftDeleteContentHistory` is called without
`ctx.Doer` being set, such as an anonymous user requesting the
`/content-history/detail` endpoint.
- Add a simple condition to always set to `canSoftDelete` to false if an
anonymous user is requesting this, this avoids a panic in the code that
assumes `ctx.Doer` is set.
- Added integration testing.

(cherry picked from commit 0b5db0dcc6)
(cherry picked from commit 30d168bcc8)
(cherry picked from commit 19be82b7ef)
(cherry picked from commit 334b703b17)
2024-02-05 16:09:42 +01:00
Earl Warren
603a44edf0
[GITEA] POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments
Refs: https://codeberg.org/forgejo/forgejo/issues/2109
(cherry picked from commit 8b4ba3dce7)
(cherry picked from commit 196edea0f9)

[GITEA] POST /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments (squash) do not implicitly create a review

If a comment already exists in a review, the comment is added. If it
is the first comment added to a review, it will implicitly create a
new review instead of adding to the existing one.

The pull_service.CreateCodeComment function is responsibe for this
behavior and it will defer to createCodeComment once the review is
determined, either because it was found or because it was created.

Rename createCodeComment into CreateCodeCommentKnownReviewID to expose
it and change the API endpoint to use it instead. Since the review is
provided by the user and verified to exist already, there is no need
for the logic implemented by CreateCodeComment.

The tests are modified to remove the initial comment from the fixture
because it was creating the false positive. I was verified to fail
without this fix.

(cherry picked from commit 6a555996dc)
(cherry picked from commit b173a0ccee)
(cherry picked from commit 838ab9740a)
2024-02-05 16:09:42 +01:00
Gergely Nagy
639b428cf4
[FEAT] API support for repository flags
Expose the repository flags feature over the API, so the flags can be
managed by a site administrator without using the web API.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit bac9f0225d)
(cherry picked from commit e7f5c1ba14)
(cherry picked from commit 95d9fe19cf)
(cherry picked from commit 7fc51991e4)
2024-02-05 16:09:42 +01:00