]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/rm/plugins/roundcube.rb
Stop pretending that we'll ever work with another DBMS.
[mailshears.git] / lib / rm / plugins / roundcube.rb
index 3dbee8ea61b948033f6ffd8df94ba86d31535e24..c25874ef856beda9deda824d0d5d31a77d5fb4a3 100644 (file)
@@ -8,12 +8,12 @@ class RoundcubeRm
   include RoundcubePlugin
   include RmPlugin
 
-  def delete_account(account)
+  def delete_user(user)
     # Delete the given username and any records in other tables
     # belonging to it.
-    raise NonexistentAccountError.new(account) if not user_exists(account)
+    raise NonexistentUserError.new(user.to_s()) if not user_exists(user)
 
-    user_id = self.get_user_id(account)
+    user_id = self.get_user_id(user)
 
     # The Roundcube developers were nice enough to include
     # DBMS-specific install and upgrade scripts, so Postgres can take
@@ -26,26 +26,14 @@ class RoundcubeRm
     # This query is of course necessary with any DBMS:
     sql_queries = ['DELETE FROM users WHERE user_id = $1::int;']
 
-    begin
-      connection = PGconn.connect(@db_host,
-                                  @db_port,
-                                  @db_opts,
-                                  @db_tty,
-                                  @db_name,
-                                  @db_user,
-                                  @db_pass)
+    connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,
+                                @db_name, @db_user, @db_pass)
 
-      sql_queries.each do |sql_query|
-        connection.query(sql_query, [user_id])
-      end
-
-      connection.close()
-
-    rescue PGError => e
-      # Pretend like we're database-agnostic in case we ever are.
-      raise DatabaseError.new(e)
+    sql_queries.each do |sql_query|
+      connection.query(sql_query, [user_id])
     end
 
+    connection.close()
   end
 
 end