X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=lib%2Fmv%2Fplugins%2Fagendav.rb;h=0324e6dc9e5003141ccf7ec6c8aacda1b3eb7130;hb=c7298aa01f95c9f6094b1bfeb05a16b20eb4de45;hp=d5858c04c5ae360dff293bcec15f5d66cf26e7e7;hpb=edf320a409cc942c632f7a64180887b7764c52c7;p=mailshears.git diff --git a/lib/mv/plugins/agendav.rb b/lib/mv/plugins/agendav.rb index d5858c0..0324e6d 100644 --- a/lib/mv/plugins/agendav.rb +++ b/lib/mv/plugins/agendav.rb @@ -8,12 +8,15 @@ class AgendavMv include AgendavPlugin include MvPlugin + def mv_user(src, dst) + # It's obviously an error if the source user does not exist. It + # would also be an error if the destination domain didn't exist; + # however, Agendav doesn't know about domains, so we let that slide. + raise NonexistentUserError.new(src.to_s()) if not user_exists(src) - def mv_domain(from, to) - # AgenDAV doesn't have a concept of domains. - end + # And it's an error if the destination user exists already. + raise UserAlreadyExistsError.new(dst.to_s()) if user_exists(dst) - def mv_user(from, to) sql_queries = ['UPDATE prefs SET username = $1 WHERE username = $2;'] sql_queries << 'UPDATE shared SET user_from = $1 WHERE user_from = $2;' sql_queries << 'UPDATE shared SET user_which = $1 WHERE user_which = $2;' @@ -28,7 +31,7 @@ class AgendavMv @db_pass) sql_queries.each do |sql_query| - connection.query(sql_query, [to, from]) + connection.query(sql_query, [dst.to_s(), src.to_s()]) end connection.close() @@ -37,7 +40,6 @@ class AgendavMv # Pretend like we're database-agnostic in case we ever are. raise DatabaseError.new(e) end - end end