-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add API for changing Avatars #25369
Add API for changing Avatars #25369
Conversation
routers/api/v1/org/avatar.go
Outdated
} | ||
|
||
st := typesniffer.DetectContentType(content) | ||
if !(st.IsImage() && !st.IsSvgImage()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we actually support SVG avatars on UI avatar upload, so it should not accept them here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was just copied from the Web UI
routers/api/v1/org/avatar.go
Outdated
if int64(len(content)) > setting.Avatar.MaxFileSize { | ||
ctx.Error(http.StatusBadRequest, "AvatarTooBig", fmt.Errorf("The avatar is to big")) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a height/width check (4000x4000 default). Can we maybe combine these checks so we don't have to duplicate them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All "pre-check" code for uploaded avatar can be removed.
The UploadAvatar calls ProcessAvatarImage, which already handle type-check, size-limit, resizing, etc, correctly.
Swagger compilation failure:
|
Head branch was pushed to by a user without write access
I don't really know what causes this. The swagger comments are the same as in other functions and I ran |
Could try updating |
I figured it out myself:
That's one of the times were you look at the code and don't find the error. |
Ah, indeed. |
This actually highlighed a bug in our action pipelines where |
#25593 will fix it. |
* giteaoffical/main: (89 commits) Move some files under repo/setting (go-gitea#25585) Following-up improvments for various PRs (go-gitea#25620) Set SSH_AUTHORIZED_KEYS_BACKUP to false (go-gitea#25412) Fix bug of branches API with tests (go-gitea#25578) [skip ci] Updated translations via Crowdin Application as a maintainer (go-gitea#25614) Adding branch-name copy to clipboard branches screen. (go-gitea#25596) Use AfterCommitId to get commit for Viewed functionality (go-gitea#25529) Fix branch commit message too long problem (go-gitea#25588) Restrict `[actions].DEFAULT_ACTIONS_URL` to only `github` or `self` (go-gitea#25581) Add API for changing Avatars (go-gitea#25369) read-only checkboxes don't appear and don't entirely act the way one might expect (go-gitea#25573) Redirect to package after version deletion (go-gitea#25594) Update emoji set to Unicode 15 (go-gitea#25595) Fix `lint-swagger` action (go-gitea#25593) Replace fomantic divider module with our own (go-gitea#25539) Add documentation about supported workflow trigger events (go-gitea#25582) Sync branches into databases (go-gitea#22743) Fix milestones deletion (go-gitea#25583) Reduce table padding globally (go-gitea#25568) ... # Conflicts: # templates/repo/wiki/revision.tmpl
This adds an API for uploading and Deleting Avatars for of Users, Repos and Organisations. I'm not sure, if this should also be added to the Admin API.
Resolves #25344