]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/postfixadmin_db_plugin.rb
1 require 'common/plugin'
4 module PostfixadminDbPlugin
5 # Code that all PostfixadminDb plugins (Prune, Rm, Mv...) will
6 # share. That is, we implement the Plugin interface.
11 cfg
= Configuration
.new()
22 def describe_account(account
)
23 # There's no other unique identifier in PostfixAdmin
28 def describe_domain(domain
)
29 # There's no other unique identifier in PostfixAdmin
37 # Just assume PostgreSQL for now.
39 connection
= PGconn
.connect(@db_host,
47 # 'ALL' is a magic domain, and we don't want it.
48 sql_query
= "SELECT domain FROM domain WHERE domain <> 'ALL';"
49 connection
.query(sql_query
) do |result
|
50 domains
= result
.field_values('domain')
54 # But pretend like we're database-agnostic in case we ever are.
55 raise DatabaseError
.new(e
)
65 # Just assume PostgreSQL for now.
67 connection
= PGconn
.connect(@db_host,
75 # If address = goto, then the alias basically says, "really
76 # deliver to that address; it's not an alias."
77 sql_query
= 'SELECT username FROM mailbox;'
78 connection
.query(sql_query
) do |result
|
79 accounts
= result
.field_values('username')
83 # But pretend like we're database-agnostic in case we ever are.
84 raise DatabaseError
.new(e
)
91 def list_domains_users(domains
)
94 # Just assume PostgreSQL for now.
96 connection
= PGconn
.connect(@db_host,
104 sql_query
= 'SELECT username FROM mailbox WHERE domain IN $1;'
106 connection
.query(sql_query
, [domains
]) do |result
|
107 usernames
= result
.field_values('username')
112 # Pretend like we're database-agnostic in case we ever are.
113 raise DatabaseError
.new(e
)