[Bps-public-commit] r16610 - sd/trunk/lib/App/SD/Replica/rt
ruz at bestpractical.com
ruz at bestpractical.com
Wed Oct 29 19:19:41 EDT 2008
Author: ruz
Date: Wed Oct 29 19:19:41 2008
New Revision: 16610
Modified:
sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm
Log:
* special case nobody and RT_System users
* always use email addresses
Modified: sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm Wed Oct 29 19:19:41 2008
@@ -246,8 +246,8 @@
}
} elsif ( $field eq 'Owner' ) {
- $new = $self->resolve_user_id_to( name => $new );
- $old = $self->resolve_user_id_to( name => $old );
+ $new = $self->resolve_user_id_to( email_address => $new );
+ $old = $self->resolve_user_id_to( email_address => $old );
}
$args{'changeset'}->add_change( { change => $change } );
@@ -257,7 +257,6 @@
$args{'ticket'}->{ $field } = $old;
$change->add_prop_change( name => $field, old => $old, new => $new );
-
}
*_recode_txn_Steal = \&_recode_txn_Set;
@@ -416,15 +415,23 @@
my $self = shift;
my $attr = shift;
my $id = shift;
- return undef unless ($id);
+ return undef unless $id;
+ local $@;
my $user = eval { RT::Client::REST::User->new( rt => $self->sync_source->rt, id => $id )->retrieve};
- if (my $err = $@) {
- warn $err;
- return $attr eq 'name' ? 'Unknown user' : 'nobody at localhost';
- }
- return $user->$attr();
-
+ if ( my $err = $@ ) {
+ warn $err;
+ return $attr eq 'name' ? 'Unknown user' : 'unknown at localhost';
+ }
+ my $name = $user->name;
+ if ( lc $name eq 'nobody' ) {
+ return $attr eq 'name' ? 'nobody' : undef;
+ }
+ elsif ( lc $name eq 'RT_System' ) {
+ return $attr eq 'name' ? 'system' : undef;
+ } else {
+ return $user->$attr();
+ }
}
memoize 'resolve_user_id_to';
More information about the Bps-public-commit
mailing list