]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/agendav_plugin.rb
Overhaul everything to get consistent error reports.
[mailshears.git] / lib / common / agendav_plugin.rb
index 7522b2cfce630a7340b69fadd5d7279ea4b9ffd9..fc19d3d60fd45fccfec195ca745de1c0d7b5b3b5 100644 (file)
@@ -1,4 +1,5 @@
 require 'common/plugin'
+require 'common/user'
 
 module AgendavPlugin
   # Code that all Agendav plugins (Prune, Rm, Mv...) will
@@ -18,25 +19,20 @@ module AgendavPlugin
 
 
   def describe_domain(domain)
-    # AgenDAV doesn't have a concept of domains.
-    return domain
+    return domain.to_s()
   end
 
-
   def describe_user(user)
-    if self.user_exists(user)
-      return "Username: #{user}"
-    else
-      return 'User not found'
-    end
+    return user.to_s()
   end
 
 
-  protected;
-
-
   def list_users()
-    usernames = []
+    #
+    # Produce a list of AgenDAV users. This is public because it's
+    # useful in testing.
+    #
+    users = []
 
     # Just assume PostgreSQL for now.
     begin
@@ -53,7 +49,7 @@ module AgendavPlugin
       sql_query += '(SELECT user_from FROM shared);'
 
       connection.query(sql_query) do |result|
-        usernames = result.field_values('username')
+        users = result.field_values('username')
       end
 
       connection.close()
@@ -62,7 +58,7 @@ module AgendavPlugin
       raise DatabaseError.new(e)
     end
 
-    return usernames
+    return users.map{ |u| User.new(u) }
   end
 
 end