]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/agendav_plugin.rb
Clean up user/domain describing in the plugins.
[mailshears.git] / lib / common / agendav_plugin.rb
index a29f3ae84a7df1d712badacfc53bc3d3f245b345..032d057c24d8e25c899ea672ae5fca50a711a8ff 100644 (file)
@@ -1,4 +1,5 @@
 require 'common/plugin'
 require 'common/plugin'
+require 'common/user'
 
 module AgendavPlugin
   # Code that all Agendav plugins (Prune, Rm, Mv...) will
 
 module AgendavPlugin
   # Code that all Agendav plugins (Prune, Rm, Mv...) will
@@ -17,26 +18,12 @@ module AgendavPlugin
   end
 
 
   end
 
 
-  def describe_domain(domain)
-    # AgenDAV doesn't have a concept of domains.
-    return domain
-  end
-
-
-  def describe_account(account)
-    if self.user_exists(account)
-      return "Username: #{account}"
-    else
-      return 'User not found'
-    end
-  end
-
-
-  protected;
-
-
   def list_users()
   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
 
     # Just assume PostgreSQL for now.
     begin
@@ -53,7 +40,7 @@ module AgendavPlugin
       sql_query += '(SELECT user_from FROM shared);'
 
       connection.query(sql_query) do |result|
       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()
       end
 
       connection.close()
@@ -62,7 +49,7 @@ module AgendavPlugin
       raise DatabaseError.new(e)
     end
 
       raise DatabaseError.new(e)
     end
 
-    return usernames
+    return users.map{ |u| User.new(u) }
   end
 
 end
   end
 
 end