From cfa7724d73db97dfcbc45214ba4d0cdb40dba037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radom=C3=ADr=20Bos=C3=A1k?= Date: Sun, 27 May 2018 10:32:46 +0200 Subject: [PATCH 1/2] Escape asterisks in README Unescaped asterisks can cause markdown text to be misinterpreted. Also syntax highlighters (e.g. in sublime text) freak out. References: [markdown spec](https://daringfireball.net/projects/markdown/syntax#em) closes #7821 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9940d8a2c..7346700b7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# diaspora* +# diaspora\* ### A privacy-aware, distributed, open source social network **master:** [![Build Status master](https://secure.travis-ci.org/diaspora/diaspora.svg?branch=master)](http://travis-ci.org/diaspora/diaspora) @@ -17,9 +17,9 @@ ## Installation -You don't have to install diaspora* to use the network. There are many servers connected to diaspora*s network which are open to anyone, and you can create an account on one of these servers. Have a look at our [tips for finding a home](https://wiki.diasporafoundation.org/Choosing_a_pod), or you can just go straight to the [list of open servers](http://podupti.me) to sign up. +You don't have to install diaspora\* to use the network. There are many servers connected to diaspora\*s network which are open to anyone, and you can create an account on one of these servers. Have a look at our [tips for finding a home](https://wiki.diasporafoundation.org/Choosing_a_pod), or you can just go straight to the [list of open servers](http://podupti.me) to sign up. -Want to own your data and install diaspora*? Whether you just want to try it out, want to install it on your server or want to contribute and need a development setup, our [installation guides](https://wiki.diasporafoundation.org/Installation) will get you started! +Want to own your data and install diaspora\*? Whether you just want to try it out, want to install it on your server or want to contribute and need a development setup, our [installation guides](https://wiki.diasporafoundation.org/Installation) will get you started! ## Questions? From 87968284ba7ff0e2478162a5906024cb8911617c Mon Sep 17 00:00:00 2001 From: cmrd Senya Date: Fri, 18 May 2018 19:22:02 +0300 Subject: [PATCH 2/2] Support fetching StatusMessage by Poll guid When public fetch is requested with Poll guid, return parent StatusMessage for it, which includes the Poll in its turn. closes #7815 --- Changelog.md | 1 + app/models/poll.rb | 2 ++ config/initializers/diaspora_federation.rb | 9 +++++++-- spec/federation_callbacks_spec.rb | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 74e65ed54..ef7b69d16 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ * Allow fonts to be served from asset host in CSP [#7825](https://github.com/diaspora/diaspora/pull/7825) ## Features +* Support fetching StatusMessage by Poll GUID [#7815](https://github.com/diaspora/diaspora/pull/7815) # 0.7.5.0 diff --git a/app/models/poll.rb b/app/models/poll.rb index 40e079062..1fd4872f4 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -15,6 +15,8 @@ class Poll < ApplicationRecord validate :enough_poll_answers validates :question, presence: true + scope :all_public, -> { joins(:status_message).where(posts: {public: true}) } + self.include_root_in_json = false def enough_poll_answers diff --git a/config/initializers/diaspora_federation.rb b/config/initializers/diaspora_federation.rb index 050a70575..1ed4e9c98 100644 --- a/config/initializers/diaspora_federation.rb +++ b/config/initializers/diaspora_federation.rb @@ -117,8 +117,13 @@ DiasporaFederation.configure do |config| end on :fetch_public_entity do |entity_type, guid| - entity = Diaspora::Federation::Mappings.model_class_for(entity_type).find_by(guid: guid, public: true) - Diaspora::Federation::Entities.post(entity) if entity.is_a? Post + entity = Diaspora::Federation::Mappings.model_class_for(entity_type).all_public.find_by(guid: guid) + case entity + when Post + Diaspora::Federation::Entities.post(entity) + when Poll + Diaspora::Federation::Entities.status_message(entity.status_message) + end end on :fetch_person_url_to do |diaspora_id, path| diff --git a/spec/federation_callbacks_spec.rb b/spec/federation_callbacks_spec.rb index 9cc318bda..aa2848019 100644 --- a/spec/federation_callbacks_spec.rb +++ b/spec/federation_callbacks_spec.rb @@ -430,6 +430,26 @@ describe "diaspora federation callbacks" do expect(entity.author).to eq(alice.diaspora_handle) end + it "fetches a StatusMessage by a Poll guid" do + post = FactoryGirl.create(:status_message, author: alice.person, public: true) + poll = FactoryGirl.create(:poll, status_message: post) + entity = DiasporaFederation.callbacks.trigger(:fetch_public_entity, "Poll", poll.guid) + + expect(entity.guid).to eq(post.guid) + expect(entity.author).to eq(alice.diaspora_handle) + expect(entity.public).to be_truthy + expect(entity.poll.guid).to eq(poll.guid) + expect(entity.poll.question).to eq(poll.question) + end + + it "doesn't fetch a private StatusMessage by a Poll guid" do + post = FactoryGirl.create(:status_message, author: alice.person, public: false) + poll = FactoryGirl.create(:poll, status_message: post) + expect( + DiasporaFederation.callbacks.trigger(:fetch_public_entity, "Poll", poll.guid) + ).to be_nil + end + it "does not fetch a private post" do post = FactoryGirl.create(:status_message, author: alice.person, public: false)