Loading app/models/comment.rb +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ class Comment < ApplicationRecord after_destroy do self.parent.update_comments_counter participation = author.participations.where(target_id: post.id).first participation = author.participations.find_by(target_id: post.id) participation.unparticipate! if participation.present? end Loading app/models/conversation.rb +5 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,11 @@ class Conversation < ApplicationRecord end def set_read(user) if visibility = self.conversation_visibilities.where(:person_id => user.person.id).first visibility = conversation_visibilities.find_by(person_id: user.person.id) return unless visibility visibility.unread = 0 visibility.save end end def participant_handles participants.map(&:diaspora_handle).join(";") Loading @@ -57,7 +57,7 @@ class Conversation < ApplicationRecord def last_author return unless @last_author.present? || messages.size > 0 @last_author_id ||= messages.pluck(:author_id).last @last_author ||= Person.includes(:profile).where(id: @last_author_id).first @last_author ||= Person.includes(:profile).find_by(id: @last_author_id) end def ordered_participants Loading app/models/like.rb +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class Like < ApplicationRecord after_destroy do self.parent.update_likes_counter participation = author.participations.where(target_id: target.id).first participation = author.participations.find_by(target_id: target.id) participation.unparticipate! if participation.present? end Loading app/models/message.rb +4 −4 Original line number Diff line number Diff line Loading @@ -15,11 +15,11 @@ class Message < ApplicationRecord end def increase_unread(user) if vis = ConversationVisibility.where(:conversation_id => self.conversation_id, :person_id => user.person.id).first vis = ConversationVisibility.find_by(conversation_id: conversation_id, person_id: user.person.id) return unless vis vis.unread += 1 vis.save end end def message @message ||= Diaspora::MessageRenderer.new text Loading app/models/person.rb +1 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ class Person < ApplicationRecord def self.find_from_guid_or_username(params) p = if params[:id].present? Person.where(:guid => params[:id]).first Person.find_by(guid: params[:id]) elsif params[:username].present? && u = User.find_by_username(params[:username]) u.person else Loading Loading
app/models/comment.rb +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ class Comment < ApplicationRecord after_destroy do self.parent.update_comments_counter participation = author.participations.where(target_id: post.id).first participation = author.participations.find_by(target_id: post.id) participation.unparticipate! if participation.present? end Loading
app/models/conversation.rb +5 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,11 @@ class Conversation < ApplicationRecord end def set_read(user) if visibility = self.conversation_visibilities.where(:person_id => user.person.id).first visibility = conversation_visibilities.find_by(person_id: user.person.id) return unless visibility visibility.unread = 0 visibility.save end end def participant_handles participants.map(&:diaspora_handle).join(";") Loading @@ -57,7 +57,7 @@ class Conversation < ApplicationRecord def last_author return unless @last_author.present? || messages.size > 0 @last_author_id ||= messages.pluck(:author_id).last @last_author ||= Person.includes(:profile).where(id: @last_author_id).first @last_author ||= Person.includes(:profile).find_by(id: @last_author_id) end def ordered_participants Loading
app/models/like.rb +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class Like < ApplicationRecord after_destroy do self.parent.update_likes_counter participation = author.participations.where(target_id: target.id).first participation = author.participations.find_by(target_id: target.id) participation.unparticipate! if participation.present? end Loading
app/models/message.rb +4 −4 Original line number Diff line number Diff line Loading @@ -15,11 +15,11 @@ class Message < ApplicationRecord end def increase_unread(user) if vis = ConversationVisibility.where(:conversation_id => self.conversation_id, :person_id => user.person.id).first vis = ConversationVisibility.find_by(conversation_id: conversation_id, person_id: user.person.id) return unless vis vis.unread += 1 vis.save end end def message @message ||= Diaspora::MessageRenderer.new text Loading
app/models/person.rb +1 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ class Person < ApplicationRecord def self.find_from_guid_or_username(params) p = if params[:id].present? Person.where(:guid => params[:id]).first Person.find_by(guid: params[:id]) elsif params[:username].present? && u = User.find_by_username(params[:username]) u.person else Loading