]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/plugins/davical.rb
Move domain removal into the plugins.
[mailshears.git] / lib / rm / plugins / davical.rb
1 require 'pg'
2
3 require 'common/davical_plugin'
4 require 'rm/rm_plugin'
5
6 class DavicalRm
7 #
8 # DAViCal only supports Postgres, so even if we ever are
9 # database-agnostic, this plugin can't be.
10 #
11 include DavicalPlugin
12 include RmPlugin
13
14
15 def delete_account(account)
16 # Delete the given username. DAViCal uses foreign keys properly
17 # and only supports postgres, so we let the ON DELETE CASCADE
18 # trigger handle most of the work.
19 sql_queries = ['DELETE FROM usr WHERE username = $1']
20
21 begin
22 connection = PGconn.connect(@db_host,
23 @db_port,
24 @db_opts,
25 @db_tty,
26 @db_name,
27 @db_user,
28 @db_pass)
29
30 sql_queries.each do |sql_query|
31 connection.query(sql_query, [account])
32 end
33
34 connection.close()
35
36 rescue PGError => e
37 # Pretend like we're database-agnostic in case we ever are.
38 raise DatabaseError.new(e)
39 end
40
41 end
42
43
44 end