]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/rm/plugins/roundcube.rb
Document everything with YARD and fix some bugs along the way.
[mailshears.git] / lib / rm / plugins / roundcube.rb
index c25874ef856beda9deda824d0d5d31a77d5fb4a3..88e88c42ab4a7683c18c246fefcc329572e1333a 100644 (file)
@@ -3,27 +3,30 @@ require 'pg'
 require 'common/roundcube_plugin'
 require 'rm/rm_plugin'
 
+# Handle removal of Roundcube users from its database. Roundcube has
+# no concept of domains.
+#
 class RoundcubeRm
 
   include RoundcubePlugin
   include RmPlugin
 
-  def delete_user(user)
-    # Delete the given username and any records in other tables
-    # belonging to it.
+  # Remove *user* from the Roundcube database. This should remove him
+  # from _every_ table in which he is referenced. Fortunately the
+  # Roundcube developers were nice enough to include DBMS-specific
+  # install and upgrade scripts, so Postgres can take advantage of ON
+  # DELETE triggers.
+  #
+  # @param user [User] the user to remove.
+  #
+  def remove_user(user)
     raise NonexistentUserError.new(user.to_s()) if not user_exists(user)
 
+    # Get the primary key for this user in the "users" table.
     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
-    # advantage of ON DELETE triggers. Here's an example:
-    #
-    #  ...
-    #  user_id integer NOT NULL
-    #    REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE
-    #
-    # This query is of course necessary with any DBMS:
+    # Thanks to the ON DELETE triggers, this will remove all child
+    # records associated with user_id too.
     sql_queries = ['DELETE FROM users WHERE user_id = $1::int;']
 
     connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,