# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Used for editing messages in a public-inbox.
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Used for editing messages in a public-inbox.
use PublicInbox::ContentId qw(content_id);
use PublicInbox::MID qw(mid_clean mids);
PublicInbox::Admin::check_require('-index');
use PublicInbox::ContentId qw(content_id);
use PublicInbox::MID qw(mid_clean mids);
PublicInbox::Admin::check_require('-index');
-require PublicInbox::MIME;
-require PublicInbox::InboxWritable;
-require PublicInbox::Import;
+use PublicInbox::MIME;
+use PublicInbox::InboxWritable;
+use PublicInbox::Import;
my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, raw => 0 };
my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, raw => 0 };
GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or
die "bad command-line args\n$usage\n";
GetOptions($opt, @PublicInbox::AdminEdit::OPT, @opt) or
die "bad command-line args\n$usage\n";
my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
unless (defined $editor) {
my $k = 'publicinbox.mailEditor';
my $editor = $ENV{MAIL_EDITOR}; # e.g. "mutt -f"
unless (defined $editor) {
my $k = 'publicinbox.mailEditor';
unless (defined $editor) {
warn "\`$k' not configured, trying \`git var GIT_EDITOR'\n";
chomp($editor = `git var GIT_EDITOR`);
unless (defined $editor) {
warn "\`$k' not configured, trying \`git var GIT_EDITOR'\n";
chomp($editor = `git var GIT_EDITOR`);
PublicInbox::AdminEdit::check_editable(\@ibxs);
my $found = {}; # cid => [ [ibx, smsg] [, [ibx, smsg] ] ]
PublicInbox::AdminEdit::check_editable(\@ibxs);
my $found = {}; # cid => [ [ibx, smsg] [, [ibx, smsg] ] ]
my $tuple = [ $ibx, $smsg ];
push @{$found->{$cid} ||= []}, $tuple
}
my $tuple = [ $ibx, $smsg ];
push @{$found->{$cid} ||= []}, $tuple
}
my $edit_fn = $edit_fh->filename;
my ($ibx, $smsg) = @{$to_edit->[0]};
my $old_raw = $ibx->msg_by_smsg($smsg);
my $edit_fn = $edit_fh->filename;
my ($ibx, $smsg) = @{$to_edit->[0]};
my $old_raw = $ibx->msg_by_smsg($smsg);