[Rt-commit] rt branch 5.0/speed-up-importer updated. rt-5.0.3-138-g51bfaca09c
BPS Git Server
git at git.bestpractical.com
Tue Nov 8 22:17:54 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/speed-up-importer has been updated
via 51bfaca09c9a5a140006619176c6ff5e7d4296a5 (commit)
from 32f8de14d50cb998860b1ba5ebb0ce01f0a62fbe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 51bfaca09c9a5a140006619176c6ff5e7d4296a5
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Nov 8 09:29:22 2022 +0800
Serialize/Import subscriptions correctly
Previously the recipients were not serialized to UIDs.
diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
index 20bbea2e3d..15e3ce6f6c 100644
--- a/lib/RT/Attribute.pm
+++ b/lib/RT/Attribute.pm
@@ -958,6 +958,22 @@ sub PostInflateFixup {
}
elsif ($self->Name eq 'Subscription') {
my $content = $self->Content;
+ for my $type ( qw/Users Groups/ ) {
+ if ( my $list = $content->{Recipients}{$type} ) {
+ my @ids;
+ for my $item ( @$list ) {
+ if ( ref $item eq 'SCALAR' ) {
+ my $obj = $importer->LookupObj($$item);
+ push @ids, $obj->Id if $obj && $obj->Id;
+ }
+ else {
+ push @ids, $item;
+ }
+ }
+ @$list = @ids;
+ }
+ }
+
if (ref($content->{DashboardId}) eq 'SCALAR') {
my $attr = $importer->LookupObj(${ $content->{DashboardId} });
if ($attr) {
@@ -1021,6 +1037,24 @@ sub Serialize {
elsif ($store{Name} eq 'Subscription') {
my $content = $self->_DeserializeContent($store{Content});
$content->{DashboardId} = \( join '-', 'RT::Attribute', $RT::Organization, $content->{DashboardId} );
+
+ # encode user/groups to be UIDs
+ for my $type (qw/Users Groups/) {
+ if ( $content->{Recipients}{$type} ) {
+ my $class = $type eq 'Users' ? 'RT::User' : 'RT::Group';
+ my @uids;
+ for my $id ( @{ $content->{Recipients}{$type} } ) {
+ my $obj = $class->new( RT->SystemUser );
+ $obj->Load($id);
+ if ( $obj->Id ) {
+ push @uids,
+ \( join '-', $class, $class eq 'RT::User' ? $obj->Name : ( $RT::Organization, $obj->Id ) );
+ }
+ }
+ $content->{Recipients}{$type} = \@uids;
+ }
+ }
+
$store{Content} = $self->_SerializeContent($content);
}
-----------------------------------------------------------------------
Summary of changes:
lib/RT/Attribute.pm | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
hooks/post-receive
--
rt
More information about the rt-commit
mailing list