From: Michael Orlitzky Date: Fri, 30 Oct 2015 02:52:59 +0000 (-0400) Subject: Move the "mv" invalid destination user check into the runner. X-Git-Tag: 0.0.1~46 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=commitdiff_plain;h=1d7d65c9583a879358de36ab1ac26b35a2805ba8;hp=861e51dd6a409cb41fa6fdac3f49195acccc6541 Move the "mv" invalid destination user check into the runner. --- 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)