[Bps-public-commit] SD branch, master, updated. 0.70-24-g18bcee4

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Sep 1 22:04:38 EDT 2009


The branch, master has been updated
       via  18bcee482e3ba3c08a1a27186656bc1038d52ab9 (commit)
      from  c9661c0249206a6d001bb7c956add99dcaa223e9 (commit)

Summary of changes:
 lib/App/SD/Replica/lighthouse/PushEncoder.pm |   32 +++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 18bcee482e3ba3c08a1a27186656bc1038d52ab9
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Sep 2 10:04:29 2009 +0800

    add integrate_comment for lighthouse push

diff --git a/lib/App/SD/Replica/lighthouse/PushEncoder.pm b/lib/App/SD/Replica/lighthouse/PushEncoder.pm
index b2ad521..22fb287 100644
--- a/lib/App/SD/Replica/lighthouse/PushEncoder.pm
+++ b/lib/App/SD/Replica/lighthouse/PushEncoder.pm
@@ -17,7 +17,6 @@ sub integrate_change {
     );
     my ( $id, $record );
 
-
     return
       if $self->sync_source->app_handle->handle->last_changeset_from_source(
         $changeset->original_source_uuid ) >= $changeset->original_sequence_no;
@@ -33,12 +32,12 @@ sub integrate_change {
                 remote_id => $id,
             );
         }
-        elsif (
-            ( $change->record_type eq 'ticket' )
-            || (    $change->record_type eq 'comment'
-                and $change->change_type eq 'add_file' )
-          )
+        elsif ( $change->record_type eq 'comment'
+            and $change->change_type eq 'add_file' )
         {
+            $id = $self->integrate_comment( $change, $changeset );
+        }
+        elsif ( $change->record_type eq 'ticket' ) {
             $id = $self->integrate_ticket_update( $change, $changeset );
         }
         else {
@@ -83,6 +82,27 @@ sub integrate_ticket_update {
     return $remote_ticket_id;
 }
 
+sub integrate_comment {
+    my $self = shift;
+    my ( $change, $changeset ) = validate_pos(
+        @_,
+        { isa => 'Prophet::Change' },
+        { isa => 'Prophet::ChangeSet' }
+    );
+
+    # Figure out the remote site's ticket ID for this change's record
+
+    my %props = map { $_->name => $_->new_value } $change->prop_changes;
+    my $ticket_id = $self->sync_source->remote_id_for_uuid( $props{'ticket'} );
+    my $ticket = $self->sync_source->lighthouse->ticket;
+    $ticket->load( $ticket_id );
+
+    my %content = ( body => $props{'content'} || '[no body]' );
+
+    $ticket->update(%content);
+    return $ticket_id;
+}
+
 sub integrate_ticket_create {
     my $self = shift;
     my ( $change, $changeset ) = validate_pos(

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list