Merge branch 'next-minor' into develop

This commit is contained in:
Benjamin Neff 2018-06-16 04:36:13 +02:00
commit f3d2a54050
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
5 changed files with 33 additions and 5 deletions

View file

@ -22,6 +22,7 @@
* Allow fonts to be served from asset host in CSP [#7825](https://github.com/diaspora/diaspora/pull/7825) * Allow fonts to be served from asset host in CSP [#7825](https://github.com/diaspora/diaspora/pull/7825)
## Features ## Features
* Support fetching StatusMessage by Poll GUID [#7815](https://github.com/diaspora/diaspora/pull/7815)
# 0.7.5.0 # 0.7.5.0

View file

@ -1,4 +1,4 @@
# diaspora* # diaspora\*
### A privacy-aware, distributed, open source social network ### 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) **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 ## 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? ## Questions?

View file

@ -15,6 +15,8 @@ class Poll < ApplicationRecord
validate :enough_poll_answers validate :enough_poll_answers
validates :question, presence: true validates :question, presence: true
scope :all_public, -> { joins(:status_message).where(posts: {public: true}) }
self.include_root_in_json = false self.include_root_in_json = false
def enough_poll_answers def enough_poll_answers

View file

@ -117,8 +117,13 @@ DiasporaFederation.configure do |config|
end end
on :fetch_public_entity do |entity_type, guid| on :fetch_public_entity do |entity_type, guid|
entity = Diaspora::Federation::Mappings.model_class_for(entity_type).find_by(guid: guid, public: true) entity = Diaspora::Federation::Mappings.model_class_for(entity_type).all_public.find_by(guid: guid)
Diaspora::Federation::Entities.post(entity) if entity.is_a? Post case entity
when Post
Diaspora::Federation::Entities.post(entity)
when Poll
Diaspora::Federation::Entities.status_message(entity.status_message)
end
end end
on :fetch_person_url_to do |diaspora_id, path| on :fetch_person_url_to do |diaspora_id, path|

View file

@ -430,6 +430,26 @@ describe "diaspora federation callbacks" do
expect(entity.author).to eq(alice.diaspora_handle) expect(entity.author).to eq(alice.diaspora_handle)
end 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 it "does not fetch a private post" do
post = FactoryGirl.create(:status_message, author: alice.person, public: false) post = FactoryGirl.create(:status_message, author: alice.person, public: false)