Skip to content

Commit 3fb864e

Browse files
committed
Merge branch 'beta' into production
* beta: Update POT files using the production database Update translations from Transifex Increase CAA bucket creation timeout to 30s Update POT files using the production database Update translations from Transifex MBS-11598: Do not generate image link if we don't have a suffix (metabrainz#2069) MBS-11590: Standardize display of empty fields in cover art edits (metabrainz#2076) MBS-11587: Block smart links: hypel.ink (metabrainz#2077) MBS-11612: Restore link to genre/delete to genre sidebar MBS-11620: Sort results of admin's search_by_email tool newest first MBS-11619: Ignore periods and +tags in e-mail admin searches MBS-11604: Add genre name to genre index title (metabrainz#2071) MBS-11611: Do not keep/add trailing slash in OC ReMix URLs (metabrainz#2072) MBS-10899: Report for releases with catnos that look like ISRCs (metabrainz#2067) Ensure CAA item ownership during upload process Check for valid mime_type in /ws/js/cover-art-upload Check for login in /ws/js/cover-art-upload Update POT files using the production database Put l() string on one line to avoid \n on .pot Update translations from Transifex MBS-9259: Add help section for the track parser (metabrainz#2046) Removing no longer needed '' defaults MBS-11550: Move PostParameters to static/scripts for translation (metabrainz#2032) MBS-11571: Warn about e-mail as a username (metabrainz#2049) MBS-11573: Load collections for ratings sidebars (metabrainz#2052) MBS-1588: Better errors for invalid CD TOC (metabrainz#2056) MBS-9251: Display ended places differently on the map (metabrainz#2051) MBBE-31: Remove now unneeded old RA checks (metabrainz#2028) MBS-11546: Allow Resident Advisor /exchange URLs for releases (metabrainz#2025) MBS-11603: Finetune DNB validation (metabrainz#2070) Use addColonText for Tracklist header Ensure privileges are encoded as a number Fix catalyst warning: don't try to trim/sanitize undef "strings" Pass public editor privs when converting editor to JSON Update the link to edit search help MBS-9376: Indicate that edit searches can be bookmarked + link docs MBS-11559: Specify tracklist is empty in Remove medium edits
2 parents 26e0d57 + fc7b947 commit 3fb864e

File tree

88 files changed

+6010
-4143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+6010
-4143
lines changed

contrib/ssssss.psgi

+71-7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ use Plack::Request;
4141
use Plack::Response;
4242
use Log::Dispatch;
4343

44+
use lib "$FindBin::Bin/../lib";
45+
use DBDefs;
46+
4447
my $log = Log::Dispatch->new(outputs => [[ 'Screen', min_level => 'info' ]] );
4548
my $imgext = 'gif|jpg|pdf|png';
4649
my $ssssss_storage = $ENV{SSSSSS_STORAGE}
@@ -72,6 +75,16 @@ sub create_bucket
7275
return $bucketdir;
7376
}
7477

78+
sub bucket_exists
79+
{
80+
my $bucket = shift;
81+
my $bucketdir = catfile($ssssss_storage, $bucket);
82+
if (-d $bucketdir) {
83+
return 1;
84+
}
85+
return 0;
86+
}
87+
7588
sub handle_options
7689
{
7790
my $response = shift->new_response(200);
@@ -80,17 +93,53 @@ sub handle_options
8093
return $response;
8194
}
8295

96+
sub check_authorization_header
97+
{
98+
my ($request) = @_;
99+
my $auth = $request->header('authorization');
100+
101+
my ($user, $pass) = $auth =~ /^LOW ([^:]+):(.+)$/;
102+
if (
103+
!defined $user ||
104+
!defined $pass ||
105+
$user ne DBDefs->COVER_ART_ARCHIVE_ACCESS_KEY ||
106+
$pass ne DBDefs->COVER_ART_ARCHIVE_SECRET_KEY
107+
) {
108+
my $response = $request->new_response(403);
109+
$response->content_type('text/xml');
110+
$response->body(q{<?xml version='1.0' encoding='UTF-8'?>
111+
<Error><Code>AccessDenied</Code></Error>});
112+
return $response;
113+
}
114+
}
115+
83116
sub handle_put
84117
{
85118
my ($request) = @_;
86119

87-
my $bucketdir = create_bucket($request->path_info);
88-
my $dest = catfile($bucketdir, $request->param('file'));
89-
$log->info("PUT, storing upload at $dest\n");
120+
my $response = check_authorization_header($request);
121+
if ($response) {
122+
return $response;
123+
}
90124

91-
open(my $fh, ">", $dest);
92-
print $fh $request->content;
93-
close($fh);
125+
my $file = $request->param('file');
126+
if ($file) {
127+
my $bucketdir = create_bucket($request->path_info);
128+
my $dest = catfile($bucketdir, $file);
129+
$log->info("PUT, storing upload at $dest\n");
130+
131+
open(my $fh, ">", $dest);
132+
print $fh $request->content;
133+
close($fh);
134+
} elsif (bucket_exists($request->path_info)) {
135+
$response = $request->new_response(409);
136+
$response->content_type('text/xml');
137+
$response->body(q{<?xml version='1.0' encoding='UTF-8'?>
138+
<Error><Code>BucketAlreadyExists</Code></Error>});
139+
return $response;
140+
} else {
141+
create_bucket($request->path_info);
142+
}
94143

95144
return $request->new_response(204);
96145
}
@@ -149,7 +198,22 @@ my %mime_types = (
149198
sub handle_get {
150199
my ($request) = @_;
151200

152-
my $filename = catfile($ssssss_storage, $request->path_info);
201+
my $path_info = $request->path_info;
202+
203+
# Simulate the only bits from
204+
# https://archive.org/services/docs/api/metadata.html that we need.
205+
#
206+
# This doesn't exactly belong in an "S3 simulator" service, but
207+
# it's simpler to have it here than to create a whole 'nother file
208+
# that has to run on a different port.
209+
if ($path_info =~ m{^/metadata/}) {
210+
my $response = $request->new_response(200);
211+
$response->content_type('application/json; charset=UTF-8');
212+
$response->body(q({"is_dark":false,"metadata":{"uploader":"[email protected]"}}));
213+
return $response;
214+
}
215+
216+
my $filename = catfile($ssssss_storage, $path_info);
153217

154218
if (-f $filename) {
155219
my ($ext) = $filename =~ m/\.($imgext)$/;

lib/DBDefs/Default.pm

+1
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ sub COVER_ART_ARCHIVE_SECRET_KEY { };
359359
sub COVER_ART_ARCHIVE_UPLOAD_PREFIXER { shift; sprintf("//%s.s3.us.archive.org/", shift) };
360360
sub COVER_ART_ARCHIVE_DOWNLOAD_PREFIX { "//coverartarchive.org" };
361361
sub COVER_ART_ARCHIVE_IA_DOWNLOAD_PREFIX { '//archive.org/download' };
362+
sub COVER_ART_ARCHIVE_IA_METADATA_PREFIX { 'https://archive.org/metadata' };
362363

363364
# Mapbox access token must be set to display area/place maps.
364365
sub MAPBOX_MAP_ID { 'mapbox/streets-v11' }

lib/MusicBrainz/Server/Constants.pm

+9-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ our %EXPORT_TAGS = (
3737
vote => _get(qr/^VOTE_/),
3838
edit_status => _get(qr/^STATUS_/),
3939
access_scope => _get(qr/^ACCESS_SCOPE_/),
40-
privileges => _get(qr/_FLAG$/),
40+
privileges => _get(qr/_FLAGS?$/),
4141
language_frequency => _get(qr/^LANGUAGE_FREQUENCY/),
4242
script_frequency => _get(qr/^SCRIPT_FREQUENCY/),
4343
election_status => [
@@ -345,6 +345,14 @@ Readonly our $LOCATION_EDITOR_FLAG => 256;
345345
Readonly our $BANNER_EDITOR_FLAG => 512;
346346
Readonly our $EDITING_DISABLED_FLAG => 1024;
347347
Readonly our $ADDING_NOTES_DISABLED_FLAG => 2048;
348+
# If you update this, also update root/utility/sanitizedEditor.js
349+
Readonly our $PUBLIC_PRIVILEGE_FLAGS => $AUTO_EDITOR_FLAG &
350+
$BOT_FLAG &
351+
$RELATIONSHIP_EDITOR_FLAG &
352+
$WIKI_TRANSCLUSION_FLAG &
353+
$ACCOUNT_ADMIN_FLAG &
354+
$LOCATION_EDITOR_FLAG &
355+
$BANNER_EDITOR_FLAG;
348356

349357
Readonly our $ELECTION_VOTE_NO => -1;
350358
Readonly our $ELECTION_VOTE_ABSTAIN => 0;

lib/MusicBrainz/Server/Controller/Artist.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ sub releases : Chained('load')
541541
);
542542
}
543543

544-
after [qw( show collections details tags aliases subscribers releases recordings works events relationships )] => sub {
544+
after [qw( show collections details tags ratings aliases subscribers releases recordings works events relationships )] => sub {
545545
my ($self, $c) = @_;
546546
$self->_stash_collections($c);
547547
};

lib/MusicBrainz/Server/Controller/CDTOC.pm

+3-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ sub attach : Local DenyWhenReadonly Edit
158158
my $cdtoc = MusicBrainz::Server::Entity::CDTOC->new_from_toc($toc)
159159
or $self->error(
160160
$c, status => HTTP_BAD_REQUEST,
161-
message => l('The provided CD TOC is not valid')
161+
message => l(
162+
'The provided CD TOC is not valid. This is probably an issue with the software you used to generate it. Try again and please report the error to your software maker if it persists, including the technical information below.')
162163
);
163164

164165
$c->stash( cdtoc => $cdtoc );
@@ -351,7 +352,7 @@ sub move : Local Edit
351352
my $medium_cdtoc = $c->model('MediumCDTOC')->get_by_id($medium_cdtoc_id)
352353
or $self->error(
353354
$c, status => HTTP_BAD_REQUEST,
354-
message => l('The provided CD TOC is not valid')
355+
message => l('The provided CD TOC ID doesn’t exist.')
355356
);
356357

357358
$c->model('CDTOC')->load($medium_cdtoc);

lib/MusicBrainz/Server/Controller/Event.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ after 'load' => sub {
5252
};
5353

5454
# Stuff that has the side bar and thus needs to display collection information
55-
after [qw( show collections details tags aliases )] => sub {
55+
after [qw( show collections details tags ratings aliases )] => sub {
5656
my ($self, $c) = @_;
5757
$self->_stash_collections($c);
5858
};

lib/MusicBrainz/Server/Controller/Genre.pm

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ with 'MusicBrainz::Server::Controller::Role::Details';
1515

1616
sub base : Chained('/') PathPart('genre') CaptureArgs(0) { }
1717

18+
after 'load' => sub {
19+
my ($self, $c) = @_;
20+
my $entity_name = $self->{entity_name};
21+
my $entity = $c->stash->{ $entity_name };
22+
$c->stash(
23+
can_delete => $c->model('Genre')->can_delete($entity->id)
24+
);
25+
};
26+
1827
sub show : PathPart('') Chained('load') {
1928
my ($self, $c) = @_;
2029

lib/MusicBrainz/Server/Controller/Label.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ sub relationships : Chained('load') PathPart('relationships') {
157157
);
158158
}
159159

160-
after [qw( show collections details tags aliases subscribers relationships )] => sub {
160+
after [qw( show collections details tags ratings aliases subscribers relationships )] => sub {
161161
my ($self, $c) = @_;
162162
$self->_stash_collections($c);
163163
};

lib/MusicBrainz/Server/Controller/Recording.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ sub fingerprints : Chained('load') PathPart('fingerprints') {
141141
}
142142

143143
# Stuff that has the sidebar and needs collection info
144-
after [qw( show collections details tags aliases fingerprints )] => sub {
144+
after [qw( show collections details tags ratings aliases fingerprints )] => sub {
145145
my ($self, $c) = @_;
146146
$self->_stash_collections($c);
147147
};

lib/MusicBrainz/Server/Controller/Release.pm

+15-2
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ sub add_cover_art : Chained('load') PathPart('add-cover-art') Edit {
263263
}
264264
);
265265

266+
my $accept = $c->req->header('Accept');
267+
my $returning_json = defined $accept &&
268+
$accept =~ m{\bapplication/json\b};
269+
266270
if ($c->form_posted_and_valid($form)) {
267271
$c->model('MB')->with_transaction(sub {
268272
$self->_insert_edit(
@@ -280,8 +284,17 @@ sub add_cover_art : Chained('load') PathPart('add-cover-art') Edit {
280284
);
281285
});
282286

283-
$c->response->redirect($c->uri_for_action('/release/cover_art', [ $entity->gid ]));
284-
$c->detach;
287+
unless ($returning_json) {
288+
$c->response->redirect($c->uri_for_action('/release/cover_art', [ $entity->gid ]));
289+
$c->detach;
290+
}
291+
} elsif ($c->form_posted) {
292+
$c->response->status(500);
293+
}
294+
295+
if ($returning_json) {
296+
$c->response->body($c->json_utf8->encode($form->TO_JSON));
297+
$c->response->content_type('application/json; charset=utf-8');
285298
}
286299
}
287300

lib/MusicBrainz/Server/Controller/ReleaseEditor.pm

+3-3
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ sub _seeded_label
393393
$result->{label} = { name => trim($name) };
394394
}
395395

396-
$result->{catalogNumber} = trim($params->{catalog_number} // '');
396+
$result->{catalogNumber} = trim($params->{catalog_number});
397397
return $result;
398398
}
399399

@@ -542,7 +542,7 @@ sub _seeded_artist_credit_name
542542
my $result = {};
543543

544544
my $name = _seeded_string($params->{name}, "$field_name.name", $errors);
545-
$result->{name} = trim($name // '');
545+
$result->{name} = trim($name);
546546

547547
if (my $gid = $params->{mbid}) {
548548
my $entity = $c->model('Artist')->get_by_gid($gid);
@@ -556,7 +556,7 @@ sub _seeded_artist_credit_name
556556
}
557557

558558
my $join = _seeded_string($params->{join_phrase}, "$field_name.join_phrase", $errors);
559-
$result->{joinPhrase} = sanitize($join // '');
559+
$result->{joinPhrase} = sanitize($join);
560560

561561
$result->{artist} //= _seeded_hash($c, \&_seeded_artist, $params->{artist},
562562
"$field_name.artist", $errors);

lib/MusicBrainz/Server/Controller/ReleaseGroup.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ sub show : Chained('load') PathPart('') {
9999
);
100100
}
101101

102-
after [qw( show collections details tags aliases )] => sub {
102+
after [qw( show collections details tags ratings aliases )] => sub {
103103
my ($self, $c) = @_;
104104
$self->_stash_collections($c);
105105
};

0 commit comments

Comments
 (0)