Merge branch 'master' into feature/mastodon_api

This commit is contained in:
Râu Cao 2025-05-18 14:46:28 +04:00
commit 71c9bd29ab
Signed by: raucao
GPG Key ID: 37036C356E56CC51
2 changed files with 11 additions and 4 deletions

View File

@ -3,8 +3,15 @@ class WebKeyDirectoryController < WellKnownController
# /.well-known/openpgpkey/hu/:hashed_username(.txt)?l=username
def show
username = params[:l] || ""
@user = User.find_by(cn: username.downcase)
if params[:l].blank?
# TODO store hashed username in db if existing implementations trigger
# this a lot
msg = "WKD request with \"l\" param omitted for hu: #{params[:hashed_username]})"
Sentry.capture_message(msg) if Setting.sentry_enabled?
http_status :bad_request and return
end
@user = User.find_by(cn: params[:l].downcase)
if @user.nil? ||
@user.pgp_pubkey.blank? ||

View File

@ -10,9 +10,9 @@ RSpec.describe "OpenPGP Web Key Directory", type: :request do
end
describe "omitted 'l' param" do
it "returns a 404 status" do
it "returns a 400 status" do
get "/.well-known/openpgpkey/hu/fmb8gw3n4zdj4xpwaziki4mwcxr1368i"
expect(response).to have_http_status(:not_found)
expect(response).to have_http_status(:bad_request)
end
end