| 1 | package Net::IMAP::Server::Command::Unsubscribe; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use base qw/Net::IMAP::Server::Command/; | ||
| 7 | |||
| 8 | sub validate { | ||
| 9 | my $self = shift; | ||
| 10 | |||
| 11 | return $self->bad_command("Log in first") if $self->connection->is_unauth; | ||
| 12 | |||
| 13 | my @options = $self->parsed_options; | ||
| 14 | return $self->bad_command("Not enough options") if @options < 1; | ||
| 15 | return $self->bad_command("Too many options") if @options > 1; | ||
| 16 | |||
| 17 | my $mailbox = $self->connection->model->lookup( @options ); | ||
| 18 | return $self->no_command("Mailbox does not exist") unless $mailbox; | ||
| 19 | |||
| 20 | return 1; | ||
| 21 | } | ||
| 22 | |||
| 23 | sub run { | ||
| 24 | my $self = shift; | ||
| 25 | |||
| 26 | my $mailbox = $self->connection->model->lookup( $self->parsed_options ); | ||
| 27 | $mailbox->subscribed(0); | ||
| 28 | |||
| 29 | $self->ok_completed(); | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; |