[Bps-public-commit] SD branch, master, updated. 0.70-38-ge5d1806
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Sep 4 02:39:43 EDT 2009
The branch, master has been updated
via e5d18062eeeaa00aaab8b06a35ee2302fedc26d6 (commit)
from 209e982ebdb2ab6283074007d39f546ac9e28827 (commit)
Summary of changes:
lib/App/SD/Replica/lighthouse.pm | 26 +++++++++++++++++++++++++-
lib/App/SD/Replica/lighthouse/PullEncoder.pm | 14 +++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit e5d18062eeeaa00aaab8b06a35ee2302fedc26d6
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Sep 4 14:33:14 2009 +0800
handle username consistently: let us use name
diff --git a/lib/App/SD/Replica/lighthouse.pm b/lib/App/SD/Replica/lighthouse.pm
index 8b3a5b1..8b15c36 100644
--- a/lib/App/SD/Replica/lighthouse.pm
+++ b/lib/App/SD/Replica/lighthouse.pm
@@ -8,6 +8,7 @@ use Memoize;
use URI;
use Memoize;
use Net::Lighthouse::Project;
+use Net::Lighthouse::User;
use Prophet::ChangeSet;
@@ -96,7 +97,30 @@ sub get_txn_list_by_date {
sub foreign_username {
my $self = shift;
- return $self->lighthouse->email;
+ my $user =
+ Net::Lighthouse::User->new( map { $_ => $self->lighthouse->$_ }
+ grep { $self->lighthouse->$_ } qw/account email password token/ );
+
+ if ( $user->token ) {
+ # so we use token, let's try to find user's name
+ require Net::Lighthouse::Token;
+ my $token = Net::Lighthouse::Token->new(
+ map { $_ => $self->lighthouse->$_ }
+ grep { $self->lighthouse->$_ } qw/account token/
+ );
+ $token->load( $self->lighthouse->token );
+ my $user = Net::Lighthouse::User->new(
+ map { $_ => $self->lighthouse->$_ }
+ grep { $self->lighthouse->$_ } qw/account token/
+ );
+ $user->load( $token->user_id );
+ return $user->name;
+ }
+ else {
+ # TODO we can't get user's name via email :/
+ # wish they augment the api so we can load via email
+ return $1 if $user->email =~ /(.*?)@/;
+ }
}
sub uuid {
diff --git a/lib/App/SD/Replica/lighthouse/PullEncoder.pm b/lib/App/SD/Replica/lighthouse/PullEncoder.pm
index 52ebab2..76e52a2 100644
--- a/lib/App/SD/Replica/lighthouse/PullEncoder.pm
+++ b/lib/App/SD/Replica/lighthouse/PullEncoder.pm
@@ -6,6 +6,7 @@ use Params::Validate qw(:all);
use Memoize;
use Time::Progress;
use DateTime;
+use Net::Lighthouse::User;
has sync_source => (
isa => 'App::SD::Replica::lighthouse',
@@ -391,7 +392,18 @@ sub resolve_user_id_to {
my $self = shift;
shift;
my $id = shift;
- return $id;
+ if ( $id =~ /^\d+$/ ) {
+ my $user = Net::Lighthouse::User->new(
+ map { $_ => $self->sync_source->lighthouse->$_ }
+ grep { $self->sync_source->lighthouse->$_ }
+ qw/account email password token/
+ );
+ $user->load( $id );
+ return $user->name;
+ }
+ else {
+ return $id;
+ }
}
__PACKAGE__->meta->make_immutable;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list