X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fcommon%2Froundcube_db_plugin.rb;h=e4e9e7fb73471d4115cd6694527a43bb139cc293;hp=364b8199e23f992c2a4744ac3ec76239a98b7714;hb=51f027b01e242737956c3ab5aecdd322d6ceeeed;hpb=e3826d8926e11763837a591986d453e9ef5d9dec diff --git a/lib/common/roundcube_db_plugin.rb b/lib/common/roundcube_db_plugin.rb index 364b819..e4e9e7f 100644 --- a/lib/common/roundcube_db_plugin.rb +++ b/lib/common/roundcube_db_plugin.rb @@ -65,4 +65,33 @@ module RoundcubeDbPlugin return user_id end + + # Uses in both prune/rm. + def get_roundcube_usernames() + usernames = [] + + # 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 users;" + connection.query(sql_query) do |result| + usernames = result.field_values('username') + end + + connection.close() + rescue PGError => e + # Pretend like we're database-agnostic in case we ever are. + raise DatabaseError.new(e) + end + + return usernames + end + end