From 1d7d65c9583a879358de36ab1ac26b35a2805ba8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 29 Oct 2015 22:52:59 -0400 Subject: [PATCH 1/1] Move the "mv" invalid destination user check into the runner. --- lib/mv/mv_runner.rb | 6 ++++++ lib/mv/plugins/postfixadmin.rb | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mv/mv_runner.rb b/lib/mv/mv_runner.rb index d2a7c5b..ee762e1 100644 --- a/lib/mv/mv_runner.rb +++ b/lib/mv/mv_runner.rb @@ -12,6 +12,12 @@ class MvRunner raise NotImplementedError.new('Only users can be moved.') end + # Handle this once so we don't have to do it in every plugin. + if not dst.include?('@') then + msg = "the destination user #{dst} is not valid" + raise InvalidUserError.new(msg) + end + begin src_description = plugin.describe_user(src) plugin.mv_user(src, dst) diff --git a/lib/mv/plugins/postfixadmin.rb b/lib/mv/plugins/postfixadmin.rb index 82ddf05..3b6d188 100644 --- a/lib/mv/plugins/postfixadmin.rb +++ b/lib/mv/plugins/postfixadmin.rb @@ -17,12 +17,6 @@ class PostfixadminMv localpart_to = user_to_parts[0] domain_to = user_to_parts[1] - if domain_to.nil? - # There was no "@" in the destination user. - msg = "the destination user #{user_to} is not valid" - raise InvalidUserError.new(msg) - end - if not domain_exists(domain_to) msg = "destination domain #{domain_to} does not exist" raise NonexistentDomainError.new(msg) -- 2.43.2