Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authordanielgrippi <danielgrippi@gmail.com>2011-07-15 02:32:04 +0400
committerRaphael Sofaer <raphael@joindiaspora.com>2011-07-22 05:22:18 +0400
commitbdc4b9f746eca12b50b5d37fd329eeb0bfa75cc5 (patch)
tree29140b1158e4b89044b84604b793e3a569f3d83b /app
parent509a435cc9c6b608923b3a03347584bda76be5e7 (diff)
marsharing reshares now grabs the post from the original poster, also fetcheer that person if they don't exist locally still need to ping for xml and give the right xml back
Diffstat (limited to 'app')
-rw-r--r--app/controllers/publics_controller.rb7
-rw-r--r--app/models/reshare.rb23
-rw-r--r--app/views/shared/_stream_element.html.haml2
3 files changed, 19 insertions, 13 deletions
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index 1b59bd1ef..c58b7f917 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -66,7 +66,12 @@ class PublicsController < ApplicationController
end
def post
- @post = Post.where(:guid => params[:guid], :public => true).includes(:author, :comments => :author).first
+
+ if params[:guid].to_s.length <= 8
+ @post = Post.where(:id => params[:guid], :public => true).includes(:author, :comments => :author).first
+ else
+ @post = Post.where(:guid => params[:guid], :public => true).includes(:author, :comments => :author).first
+ end
#hax to upgrade logged in users who can comment
if @post
diff --git a/app/models/reshare.rb b/app/models/reshare.rb
index fb1c59542..8eb0303d7 100644
--- a/app/models/reshare.rb
+++ b/app/models/reshare.rb
@@ -1,4 +1,5 @@
class Reshare < Post
+
belongs_to :root, :class_name => 'Post'
validate :root_must_be_public
attr_accessible :root_id, :public
@@ -6,8 +7,6 @@ class Reshare < Post
xml_attr :root_diaspora_id
xml_attr :root_guid
- attr_accessible :root_diaspora_id, :root_guid
-
before_validation do
self.public = true
end
@@ -15,19 +14,10 @@ class Reshare < Post
def root_guid
self.root.guid
end
- def root_guid= rg
- #self.root = Post.where(:guid => rg).first
- debugger
- person = Person.where(:diaspora_handle => self[:root_diaspora_id]).first
- Faraday.get(person.url + public_post_path(:guid => rg))
- end
def root_diaspora_id
self.root.author.diaspora_handle
end
- def root_diaspora_id= id
- Webfinger.new(id).fetch
- end
def receive(user, person)
local_reshare = Reshare.where(:guid => self.guid).first
@@ -45,6 +35,17 @@ class Reshare < Post
private
+ def after_parse
+ root_author = Webfinger.new(@root_diaspora_id).fetch
+ root_author.save!
+
+ unless self.root = Post.where(:guid => @root_guid).first
+ self.root = Diaspora::Parser.from_xml(Faraday.get(root_author.url + "/p/#{@root_guid}").body)
+ self.root.save!
+ end
+
+ end
+
def root_must_be_public
if self.root.nil? || !self.root.public
errors[:base] << "you must reshare public posts"
diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml
index a4a1f735f..0a4a3ef13 100644
--- a/app/views/shared/_stream_element.html.haml
+++ b/app/views/shared/_stream_element.html.haml
@@ -9,7 +9,7 @@
- else
.right.controls
- = link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
+ = link_to image_tag('deletelabel.png'), post_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete stream_element_delete", :title => t('hide')
.undo_text.hidden
= t('post_visibilites.update.post_hidden', :name => post.author.name)