]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/agendav_plugin.rb
Use semantic bound on pg library.
[mailshears.git] / lib / common / agendav_plugin.rb
index fc19d3d60fd45fccfec195ca745de1c0d7b5b3b5..9af7b01519b40aca2870176948ed4f0ac6f950cb 100644 (file)
@@ -18,15 +18,6 @@ module AgendavPlugin
   end
 
 
-  def describe_domain(domain)
-    return domain.to_s()
-  end
-
-  def describe_user(user)
-    return user.to_s()
-  end
-
-
   def list_users()
     #
     # Produce a list of AgenDAV users. This is public because it's
@@ -34,30 +25,19 @@ module AgendavPlugin
     #
     users = []
 
-    # Just assume PostgreSQL for now.
-    begin
-      connection = PGconn.connect(@db_host,
-                                  @db_port,
-                                  @db_opts,
-                                  @db_tty,
-                                  @db_name,
-                                  @db_user,
-                                  @db_pass)
-
-      sql_query  = '(SELECT username FROM prefs)'
-      sql_query += 'UNION'
-      sql_query += '(SELECT user_from FROM shared);'
+    connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,
+                                @db_name, @db_user, @db_pass)
 
-      connection.query(sql_query) do |result|
-        users = result.field_values('username')
-      end
+    sql_query  = '(SELECT username FROM prefs)'
+    sql_query += 'UNION'
+    sql_query += '(SELECT user_from FROM shared);'
 
-      connection.close()
-    rescue PGError => e
-      # Pretend like we're database-agnostic in case we ever are.
-      raise DatabaseError.new(e)
+    connection.query(sql_query) do |result|
+      users = result.field_values('username')
     end
 
+    connection.close()
+
     return users.map{ |u| User.new(u) }
   end