From 0c5c17f5e2af8d61b3160ba7fea3340468437d8e Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Mon, 20 Jan 2014 22:00:26 +0100 Subject: [PATCH] fix regression in conversations causing an infinite recursion (fix #4715) (cherry picked from commit 5c059b2925db882fadbd6b908e6706eb7fd5f379) Conflicts: Changelog.md --- Changelog.md | 5 +++++ app/models/message.rb | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 9a1c94b03..38e26bf25 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +# 0.3.0.1 + +## Bug fixes +* Fix regression caused by using after_commit with nested '#save' which lead to an infinite recursion [#4715](https://github.com/diaspora/diaspora/issues/4715) + # 0.3.0.0 ## Pod statistics diff --git a/app/models/message.rb b/app/models/message.rb index c0bbcb38a..60de53d3d 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -11,13 +11,14 @@ class Message < ActiveRecord::Base belongs_to :author, :class_name => 'Person' belongs_to :conversation, :touch => true - + delegate :name, to: :author, prefix: true validates :text, :presence => true validate :participant_of_parent_conversation - after_commit :on => :create do + after_create do # don't use 'after_commit' here since there is a call to 'save!' + # inside, which would cause an infinite recursion #sign comment as commenter self.author_signature = self.sign_with_key(self.author.owner.encryption_key) if self.author.owner