Move the "mv" invalid destination user check into the runner.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Oct 2015 02:52:59 +0000 (22:52 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Oct 2015 02:52:59 +0000 (22:52 -0400)
lib/mv/mv_runner.rb
lib/mv/plugins/postfixadmin.rb

index d2a7c5ba01d4664882a14b9b539f76f1f578d709..ee762e1e70cf4198c1630b3404973d20c75ac264 100644 (file)
@@ -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)
index 82ddf055c4b1bd747fb6f1319e344ad8b26c3055..3b6d1884975b939bbf7bd01f370fbde10cdf653a 100644 (file)
@@ -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)