X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fmv%2Fplugins%2Fagendav.rb;fp=lib%2Fmv%2Fplugins%2Fagendav.rb;h=0324e6dc9e5003141ccf7ec6c8aacda1b3eb7130;hp=9c508c9866ca3a37df0ea7ca5d17c603690bc0eb;hb=f819b178c5c1cb8adda0182c610e5c52fad8bea7;hpb=8a3e804a4c5f33bee1d80243be6b139e45f07a48 diff --git a/lib/mv/plugins/agendav.rb b/lib/mv/plugins/agendav.rb index 9c508c9..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()