1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 package PublicInbox::AltId;
7 use URI::Escape qw(uri_unescape);
9 # spec: TYPE:PREFIX:param1=value1¶m2=value2&...
10 # Example: serial:gmane:file=/path/to/altmsgmap.sqlite3
12 my ($class, $inbox, $spec) = @_;
13 my ($type, $prefix, $query) = split(/:/, $spec, 3);
14 $type eq 'serial' or die "non-serial not supported, yet\n";
16 require PublicInbox::Msgmap;
19 my ($k, $v) = split(/=/, uri_unescape($_), 2);
20 $v = '' unless defined $v;
22 } split(/[&;]/, $query);
23 my $f = $params{file} or die "file: required for $type spec $spec\n";
24 unless (index($f, '/') == 0) {
25 $f = "$inbox->{mainrepo}/public-inbox/$f";
28 mm_alt => PublicInbox::Msgmap->new_file($f),
29 xprefix => 'X'.uc($prefix),
34 my ($self, $mid) = @_;
35 $self->{mm_alt}->num_for($mid);