mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-06 08:34 am

[dw-free] Error handling for WTF backend

[commit: http://hg.dwscoalition.org/dw-free/rev/3f64af57ebea]

http://bugs.dwscoalition.org/show_bug.cgi?id=368

Make add_edge call the methods to validate if the user can watch/trust.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/DW/User/Edges/WatchTrust.pm
--------------------------------------------------------------------------------
diff -r 817d2372b6fa -r 3f64af57ebea cgi-bin/DW/User/Edges/WatchTrust.pm
--- a/cgi-bin/DW/User/Edges/WatchTrust.pm	Fri Mar 06 08:28:34 2009 +0000
+++ b/cgi-bin/DW/User/Edges/WatchTrust.pm	Fri Mar 06 08:34:51 2009 +0000
@@ -69,6 +69,10 @@ sub _add_wt_edge {
     $watch_edge ||= {};
     my $do_trust = $trust_edge ? 1 : 0;
     $trust_edge ||= {};
+
+    # throw errors if we're not allowed
+    return 0 if $do_watch && ! $from_u->can_watch( $to_u );
+    return 0 if $do_trust && ! $from_u->can_trust( $to_u );
 
     # get current record, so we know what to modify
     my $dbh = LJ::get_db_writer();
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org