user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
e26e9815610a3680aab3e6dc05a1321f9f94c1e9 blob 1238 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
# Copyright (C) 2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>

# common writer code for IMAP (and later, JMAP)
package PublicInbox::NetWriter;
use strict;
use v5.10.1;
use parent qw(PublicInbox::NetReader);
use PublicInbox::Smsg;
use PublicInbox::MsgTime qw(msg_timestamp);

my %IMAPkw2flags;
@IMAPkw2flags{values %PublicInbox::NetReader::IMAPflags2kw} =
				keys %PublicInbox::NetReader::IMAPflags2kw;

sub imap_append {
	my ($mic, $folder, $bref, $smsg, $eml) = @_;
	$bref //= \($eml->as_string);
	$smsg //= bless {}, 'PublicInbox::Smsg';
	bless($smsg, 'PublicInbox::Smsg') if ref($smsg) eq 'HASH';
	$smsg->{ts} //= msg_timestamp($eml // PublicInbox::Eml->new($$bref));
	my @f = map { $IMAPkw2flags{$_} } @{$smsg->{kw}};
	$mic->append_string($folder, $$bref, "@f", $smsg->internaldate) or
		die "APPEND $folder: $@";
}

sub imap_delete_all {
	my ($self, $url) = @_;
	my $uri = PublicInbox::URIimap->new($url);
	my $sec = $self->can('uri_section')->($uri);
	local $0 = $uri->mailbox." $sec";
	my $mic = $self->mic_get($uri) or die "E: not connected: $@";
	$mic->select($uri->mailbox) or return; # non-existent
	if ($mic->delete_message('1:*')) {
		$mic->expunge;
	}
}

1;
debug log:

solving e26e9815 ...
found e26e9815 in public-inbox.git

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).