Merge branch 'master' of github.com:diaspora/diaspora into import
This commit is contained in:
commit
59c3be41b3
34 changed files with 668 additions and 212 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -17,6 +17,7 @@ nbproject
|
||||||
gpg/diaspora-development/*.gpg
|
gpg/diaspora-development/*.gpg
|
||||||
gpg/diaspora-production/*.gpg
|
gpg/diaspora-production/*.gpg
|
||||||
gpg/*/random_seed
|
gpg/*/random_seed
|
||||||
|
patches-*
|
||||||
public/uploads/*
|
public/uploads/*
|
||||||
public/source.tar
|
public/source.tar
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
|
|
|
||||||
4
Gemfile
4
Gemfile
|
|
@ -8,7 +8,7 @@ gem 'devise', '1.1.3'
|
||||||
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
|
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
|
||||||
gem 'devise_invitable', '~> 0.3.4'
|
gem 'devise_invitable', '~> 0.3.4'
|
||||||
#Mongo
|
#Mongo
|
||||||
gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git'
|
gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git'
|
||||||
gem 'bson_ext', '1.1'
|
gem 'bson_ext', '1.1'
|
||||||
gem 'bson', '1.1'
|
gem 'bson', '1.1'
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ gem 'thin'
|
||||||
|
|
||||||
#Websocket
|
#Websocket
|
||||||
gem 'em-websocket'
|
gem 'em-websocket'
|
||||||
gem 'magent', :git => 'http://github.com/dcu/magent.git'
|
gem 'magent', :git => 'git://github.com/dcu/magent.git'
|
||||||
|
|
||||||
#File uploading
|
#File uploading
|
||||||
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
|
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
|
||||||
|
|
|
||||||
42
Gemfile.lock
42
Gemfile.lock
|
|
@ -13,6 +13,15 @@ GIT
|
||||||
devise-mongo_mapper (0.0.1)
|
devise-mongo_mapper (0.0.1)
|
||||||
devise (~> 1.1.0)
|
devise (~> 1.1.0)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/dcu/magent.git
|
||||||
|
revision: fe08cc6e9d4c1772035f84bcfb665d17b00ac625
|
||||||
|
specs:
|
||||||
|
magent (1.0.0)
|
||||||
|
em-websocket
|
||||||
|
mongo
|
||||||
|
uuidtools
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/igrigorik/em-http-request.git
|
remote: git://github.com/igrigorik/em-http-request.git
|
||||||
revision: bf62d67fc72d6e701be5037e239dd470194b8e45
|
revision: bf62d67fc72d6e701be5037e239dd470194b8e45
|
||||||
|
|
@ -22,6 +31,16 @@ GIT
|
||||||
addressable (>= 2.0.0)
|
addressable (>= 2.0.0)
|
||||||
eventmachine (>= 0.12.9)
|
eventmachine (>= 0.12.9)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/jnunemaker/mongomapper.git
|
||||||
|
revision: fd59b0ab068be7321f8e84b9dc12fb4fa6b8535d
|
||||||
|
branch: rails3
|
||||||
|
specs:
|
||||||
|
mongo_mapper (0.8.4)
|
||||||
|
activemodel (~> 3.0.0)
|
||||||
|
activesupport (~> 3.0.0)
|
||||||
|
plucky (~> 0.3.6)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/rsofaer/carrierwave.git
|
remote: git://github.com/rsofaer/carrierwave.git
|
||||||
revision: 9edb8bdddd2236742a85bfd7b260387498d01f88
|
revision: 9edb8bdddd2236742a85bfd7b260387498d01f88
|
||||||
|
|
@ -47,25 +66,6 @@ GIT
|
||||||
capistrano (>= 2.5.5)
|
capistrano (>= 2.5.5)
|
||||||
highline (>= 1.4.0)
|
highline (>= 1.4.0)
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: http://github.com/dcu/magent.git
|
|
||||||
revision: 5d664351b305141158fc69fc495456414821adb3
|
|
||||||
specs:
|
|
||||||
magent (1.0.0)
|
|
||||||
em-websocket
|
|
||||||
mongo
|
|
||||||
uuidtools
|
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: http://github.com/jnunemaker/mongomapper.git
|
|
||||||
revision: fd59b0ab068be7321f8e84b9dc12fb4fa6b8535d
|
|
||||||
branch: rails3
|
|
||||||
specs:
|
|
||||||
mongo_mapper (0.8.4)
|
|
||||||
activemodel (~> 3.0.0)
|
|
||||||
activesupport (~> 3.0.0)
|
|
||||||
plucky (~> 0.3.6)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
|
@ -96,7 +96,7 @@ GEM
|
||||||
activemodel (= 3.0.0)
|
activemodel (= 3.0.0)
|
||||||
activesupport (= 3.0.0)
|
activesupport (= 3.0.0)
|
||||||
activesupport (3.0.0)
|
activesupport (3.0.0)
|
||||||
addressable (2.2.1)
|
addressable (2.2.2)
|
||||||
arel (1.0.1)
|
arel (1.0.1)
|
||||||
activesupport (~> 3.0.0)
|
activesupport (~> 3.0.0)
|
||||||
aws (2.3.21)
|
aws (2.3.21)
|
||||||
|
|
@ -172,7 +172,7 @@ GEM
|
||||||
mini_fb (1.1.3)
|
mini_fb (1.1.3)
|
||||||
hashie
|
hashie
|
||||||
rest-client
|
rest-client
|
||||||
mini_magick (2.1)
|
mini_magick (2.3)
|
||||||
subexec (~> 0.0.4)
|
subexec (~> 0.0.4)
|
||||||
mocha (0.9.8)
|
mocha (0.9.8)
|
||||||
rake
|
rake
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class Person
|
||||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||||
|
|
||||||
def self.search(query)
|
def self.search(query)
|
||||||
|
return Person.all if query.to_s.empty?
|
||||||
qTokens = query.to_s.strip.split(" ")
|
qTokens = query.to_s.strip.split(" ")
|
||||||
fullQueryText = Regexp.escape( query.to_s.strip )
|
fullQueryText = Regexp.escape( query.to_s.strip )
|
||||||
p = []
|
p = []
|
||||||
|
|
|
||||||
5
ci.sh
5
ci.sh
|
|
@ -4,6 +4,7 @@ echo "**************************************************************************
|
||||||
echo "* ruby 1.8.7-p249 build *" &&
|
echo "* ruby 1.8.7-p249 build *" &&
|
||||||
echo "*************************************************************************************************" &&
|
echo "*************************************************************************************************" &&
|
||||||
echo "" &&
|
echo "" &&
|
||||||
|
rm Gemfile.lock &&
|
||||||
source /usr/local/rvm/scripts/rvm &&
|
source /usr/local/rvm/scripts/rvm &&
|
||||||
rvm use ruby-1.8.7-p249 &&
|
rvm use ruby-1.8.7-p249 &&
|
||||||
bundle install &&
|
bundle install &&
|
||||||
|
|
@ -13,8 +14,8 @@ echo "**************************************************************************
|
||||||
echo "* ruby 1.9.2-p0 build *" &&
|
echo "* ruby 1.9.2-p0 build *" &&
|
||||||
echo "*************************************************************************************************" &&
|
echo "*************************************************************************************************" &&
|
||||||
echo "" &&
|
echo "" &&
|
||||||
|
rm Gemfile.lock &&
|
||||||
source /usr/local/rvm/scripts/rvm &&
|
source /usr/local/rvm/scripts/rvm &&
|
||||||
rvm use ruby-1.9.2-p0 &&
|
rvm use ruby-1.9.2-p0 &&
|
||||||
bundle install &&
|
bundle install &&
|
||||||
bundle exec rake ci &&
|
bundle exec rake ci
|
||||||
rm Gemfile.lock
|
|
||||||
|
|
|
||||||
|
|
@ -5,28 +5,49 @@ module Diaspora
|
||||||
salmon = Salmon::SalmonSlap.parse salmon_xml, self
|
salmon = Salmon::SalmonSlap.parse salmon_xml, self
|
||||||
if salmon.verified_for_key?(salmon.author.public_key)
|
if salmon.verified_for_key?(salmon.author.public_key)
|
||||||
Rails.logger.info("data in salmon: #{salmon.parsed_data}")
|
Rails.logger.info("data in salmon: #{salmon.parsed_data}")
|
||||||
self.receive(salmon.parsed_data)
|
self.receive(salmon.parsed_data, salmon.author)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive xml
|
def receive xml, salmon_author
|
||||||
object = Diaspora::Parser.from_xml(xml)
|
object = Diaspora::Parser.from_xml(xml)
|
||||||
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
|
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
|
||||||
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||||
|
|
||||||
if object.is_a? Retraction
|
sender_in_xml = sender(object, xml)
|
||||||
receive_retraction object, xml
|
|
||||||
elsif object.is_a? Request
|
if (salmon_author == sender_in_xml)
|
||||||
receive_request object, xml
|
if object.is_a? Retraction
|
||||||
elsif object.is_a? Profile
|
receive_retraction object, xml
|
||||||
receive_profile object, xml
|
elsif object.is_a? Request
|
||||||
elsif object.is_a?(Comment)
|
receive_request object, sender_in_xml
|
||||||
receive_comment object, xml
|
elsif object.is_a? Profile
|
||||||
|
receive_profile object, xml
|
||||||
|
elsif object.is_a?(Comment)
|
||||||
|
receive_comment object, xml
|
||||||
|
else
|
||||||
|
receive_post object, xml
|
||||||
|
end
|
||||||
else
|
else
|
||||||
receive_post object, xml
|
raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sender(object, xml)
|
||||||
|
if object.is_a? Retraction
|
||||||
|
sender = object.person
|
||||||
|
elsif object.is_a? Request
|
||||||
|
sender = object.person
|
||||||
|
elsif object.is_a? Profile
|
||||||
|
sender = Diaspora::Parser.owner_id_from_xml xml
|
||||||
|
elsif object.is_a?(Comment)
|
||||||
|
sender = (owns?(object.post))? object.person : object.post.person
|
||||||
|
else
|
||||||
|
sender = object.person
|
||||||
|
end
|
||||||
|
sender
|
||||||
|
end
|
||||||
|
|
||||||
def receive_retraction retraction, xml
|
def receive_retraction retraction, xml
|
||||||
if retraction.type == 'Person'
|
if retraction.type == 'Person'
|
||||||
Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}")
|
Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}")
|
||||||
|
|
@ -40,8 +61,7 @@ module Diaspora
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive_request request, xml
|
def receive_request request, person
|
||||||
person = Diaspora::Parser.parse_or_find_person_from_xml( xml )
|
|
||||||
person.serialized_public_key ||= request.exported_key
|
person.serialized_public_key ||= request.exported_key
|
||||||
request.person = person
|
request.person = person
|
||||||
request.person.save
|
request.person.save
|
||||||
|
|
@ -59,12 +79,12 @@ module Diaspora
|
||||||
|
|
||||||
def receive_comment comment, xml
|
def receive_comment comment, xml
|
||||||
comment.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if comment.person.nil?
|
comment.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if comment.person.nil?
|
||||||
|
raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature
|
||||||
self.visible_people = self.visible_people | [comment.person]
|
self.visible_people = self.visible_people | [comment.person]
|
||||||
self.save
|
self.save
|
||||||
Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil?
|
Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil?
|
||||||
comment.person.save
|
comment.person.save
|
||||||
Rails.logger.debug("From: #{comment.person.inspect}") if comment.person
|
Rails.logger.debug("From: #{comment.person.inspect}") if comment.person
|
||||||
raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature
|
|
||||||
comment.save
|
comment.save
|
||||||
unless owns?(comment)
|
unless owns?(comment)
|
||||||
dispatch_comment comment
|
dispatch_comment comment
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ HEADER
|
||||||
if @author
|
if @author
|
||||||
@author
|
@author
|
||||||
else
|
else
|
||||||
Person.by_webfinger @author_email
|
@author ||= Person.by_webfinger @author_email
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
%define git_release HEAD
|
%define git_release 1010092232_b313272
|
||||||
|
|
||||||
Summary: A social network server
|
Summary: A social network server
|
||||||
Name: diaspora
|
Name: diaspora
|
||||||
Version: 0.0.1
|
Version: 0.0
|
||||||
Release: 1.%{git_release}%{?dist}
|
Release: 1.%{git_release}%{?dist}
|
||||||
License: AGPLv3
|
License: AGPLv3
|
||||||
Group: Applications/Communications
|
Group: Applications/Communications
|
||||||
|
|
@ -19,7 +19,7 @@ BuildRoot: %{_rmpdir}/not-used-in-fedora/
|
||||||
|
|
||||||
Requires: mongodb-server
|
Requires: mongodb-server
|
||||||
Requires: ruby(abi) = 1.8
|
Requires: ruby(abi) = 1.8
|
||||||
Requires: diaspora-bundle = %{version}
|
Requires: diaspora-bundle = 0.0-1.1010081636_d1a4ee0.fc13
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
|
@ -109,7 +109,8 @@ rm -fr $RPM_BUILD_ROOT
|
||||||
%{_sysconfdir}/init.d/diaspora-wsd
|
%{_sysconfdir}/init.d/diaspora-wsd
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Fri Sep 24 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1009280542_859ec2d
|
* Fri Sep 24 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1010092232_b313272.fc13
|
||||||
|
|
||||||
- Initial attempt to create a spec fi+le
|
- Initial attempt to create a spec fi+le
|
||||||
|
|
||||||
# rubygem-term-ansicolor in repo (1.0.5)
|
# rubygem-term-ansicolor in repo (1.0.5)
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,7 @@ function checkout()
|
||||||
git clone --quiet $GIT_REPO;
|
git clone --quiet $GIT_REPO;
|
||||||
(
|
(
|
||||||
cd diaspora;
|
cd diaspora;
|
||||||
git remote add upstream \
|
git remote add upstream $GIT_REPO
|
||||||
git://github.com/diaspora/diaspora.git
|
|
||||||
for p in ../../*.patch; do
|
for p in ../../*.patch; do
|
||||||
git apply --whitespace=fix $p > /dev/null
|
git apply --whitespace=fix $p > /dev/null
|
||||||
done &> /dev/null || :
|
done &> /dev/null || :
|
||||||
|
|
@ -159,7 +158,6 @@ function make_src
|
||||||
cd dist
|
cd dist
|
||||||
mkdir ${RELEASE_DIR}/master
|
mkdir ${RELEASE_DIR}/master
|
||||||
cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master
|
cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master
|
||||||
mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR}
|
|
||||||
(
|
(
|
||||||
cd ${RELEASE_DIR}/master
|
cd ${RELEASE_DIR}/master
|
||||||
git show --name-only > config/gitversion
|
git show --name-only > config/gitversion
|
||||||
|
|
@ -168,6 +166,9 @@ function make_src
|
||||||
find $PWD -name .git\* | xargs rm -rf
|
find $PWD -name .git\* | xargs rm -rf
|
||||||
rm -rf .bundle
|
rm -rf .bundle
|
||||||
/usr/bin/patch -p1 -s <../../../add-bundle.diff
|
/usr/bin/patch -p1 -s <../../../add-bundle.diff
|
||||||
|
for p in ../../../*.patch; do
|
||||||
|
/usr/bin/patch -p1 -s < $p
|
||||||
|
done &> /dev/null || :
|
||||||
)
|
)
|
||||||
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \
|
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \
|
||||||
rm -rf ${RELEASE_DIR}
|
rm -rf ${RELEASE_DIR}
|
||||||
|
|
@ -203,7 +204,8 @@ function make_bundle()
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
echo "Bundle: dist/$bundle_name.tar.gz"
|
echo "Repo: $GIT_REPO"
|
||||||
|
echo "Bundle: dist/$bundle_name.tar.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -278,9 +280,8 @@ function usage()
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
commit='HEAD'
|
commit='HEAD'
|
||||||
while getopts ":r:c:h" opt
|
while getopts ":r:c:u:h" opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
u) GIT_REPO="$OPTARG"
|
u) GIT_REPO="$OPTARG"
|
||||||
|
|
|
||||||
3
pkg/ubuntu/.gitignore
vendored
Normal file
3
pkg/ubuntu/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
patches-*
|
||||||
|
dist
|
||||||
|
series
|
||||||
85
pkg/ubuntu/README.md
Normal file
85
pkg/ubuntu/README.md
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
## Package-oriented install for ubuntu.
|
||||||
|
|
||||||
|
Here are somediaspora-installdiaspora-install scripts to install diaspora on Ubuntu. They are designed to
|
||||||
|
work as a first step towards packaging, but should be usable as is.
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Bootstrap the distribution from git:
|
||||||
|
sudo apt-get install git-core
|
||||||
|
git clone git://github.com/diaspora/diaspora.git
|
||||||
|
cd diaspora/pkg/ubuntu
|
||||||
|
|
||||||
|
Install the dependencies (a good time for a coffe break)
|
||||||
|
sudo ./diaspora-install-deps
|
||||||
|
|
||||||
|
Create and install the diaspora bundle and application:
|
||||||
|
./make-dist.sh bundle
|
||||||
|
sudo ./diaspora-bundle-install dist/diaspora-bundle-*.tar.gz
|
||||||
|
|
||||||
|
./make-dist.sh source
|
||||||
|
sudo ./diaspora-install dist/diaspora-0.0*.tar.gz
|
||||||
|
|
||||||
|
Initiate and start the server;
|
||||||
|
sudo ./diaspora-setup
|
||||||
|
sudo su - diaspora
|
||||||
|
cd /usr/share/diaspora/master
|
||||||
|
./script/server
|
||||||
|
|
||||||
|
### Upgrading
|
||||||
|
|
||||||
|
The normal procedure to update is to just
|
||||||
|
$ sudo su - diaspora
|
||||||
|
$ cd /usr/share/diaspora/master/pkg/ubuntu
|
||||||
|
$ ./make-dist.sh bundle
|
||||||
|
$ ./make-dist.sh source
|
||||||
|
|
||||||
|
And then use diaspore-install and diaspora-install-bundle as above.
|
||||||
|
|
||||||
|
It's necessary to always have the correct bundle. The easy way is to just
|
||||||
|
$ ./make-dist.sh bundle
|
||||||
|
|
||||||
|
Repo: http://github.com/diaspora/diaspora.git
|
||||||
|
Bundle: dist/diaspora-bundle-0.0-1010111342_afad554.tar.gz
|
||||||
|
|
||||||
|
The command will return the last built bundle (which is cached) if it's
|
||||||
|
OK to use. If it's not, it will build a new.
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
The application lives in /usr/share/diaspora/master. All writable areas
|
||||||
|
(log, uploads, tmp) are links to /var/lib/diaspora. The config file lives
|
||||||
|
in /etc/diaspora. All files in /usr/share are read-only, owned by root.
|
||||||
|
|
||||||
|
The bundle lives in /usr/lib/diaspora-bundle, readonly, owned by root.
|
||||||
|
Application finds it through the patched .bundle/config in root dir.
|
||||||
|
|
||||||
|
Once diaspora ins installed ,makedist.sh et. al. are available in
|
||||||
|
/usr/share/diaspora/master/pkg/ubuntu, so there's no need to checkout
|
||||||
|
the stuff using git in this case.
|
||||||
|
|
||||||
|
The user diaspora is added during install.
|
||||||
|
|
||||||
|
Tools used for building package are installed globally. All of diasporas
|
||||||
|
dependencies lives in the nothing is insalled by user or on system level.
|
||||||
|
|
||||||
|
make-dist.sh accepts arguments to get a specified commit and/or use another
|
||||||
|
repo.
|
||||||
|
|
||||||
|
This has been tested on a Ubuntu 32-bit 10.10 , clean server and on 10.04
|
||||||
|
Lucid desktop, also clean installation.
|
||||||
|
|
||||||
|
mongodb is having problems occasionally. Sometimes the dependencies are not
|
||||||
|
installed, and mongod refuses to start. invoke /usr/bin/mongod -f /etc/mongodb.conf
|
||||||
|
fo test. The lockfile /var/lib/mongodb/mongod.conf is also a potential
|
||||||
|
problem. Remove to make it start again.
|
||||||
|
|
||||||
|
The diaspora-wsd is just placeholder FTM, it does **not** work.
|
||||||
|
|
||||||
|
Please, report any problems!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
11
pkg/ubuntu/add-bundle.diff
Normal file
11
pkg/ubuntu/add-bundle.diff
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
diff --git a/.bundle/config b/.bundle/config
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..1c3e2ce
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/.bundle/config
|
||||||
|
@@ -0,0 +1,5 @@
|
||||||
|
+---
|
||||||
|
+BUNDLE_FROZEN: "1"
|
||||||
|
+BUNDLE_DISABLE_SHARED_GEMS: "1"
|
||||||
|
+BUNDLE_WITHOUT: test:rdoc
|
||||||
|
+BUNDLE_PATH: vendor/bundle
|
||||||
26
pkg/ubuntu/diaspora-bundle-install
Executable file
26
pkg/ubuntu/diaspora-bundle-install
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test "$(perl -e 'print $>')" = "0" || {
|
||||||
|
echo "You need to be root to do this, giving up"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
test $# = "1" || {
|
||||||
|
echo "Usage: diaspora-bundle-install <diaspora-bundle-VERSION-RELEASE.tar.gz>"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
test -r "$1" || {
|
||||||
|
echo "Cannot open $1"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
rm -rf /usr/lib/diaspora-bundle
|
||||||
|
tar xf $1 -C /usr/lib
|
||||||
|
|
||||||
|
cd /usr/lib
|
||||||
|
mv $(basename $1 .tar.gz) diaspora-bundle
|
||||||
|
mkdir -p /usr/share/doc/diaspora-bundle || :
|
||||||
|
cd /usr/lib/diaspora-bundle
|
||||||
|
|
||||||
|
cp AUTHORS GNU-AGPL-3.0 COPYRIGHT /usr/share/doc/diaspora-bundle
|
||||||
71
pkg/ubuntu/diaspora-install
Executable file
71
pkg/ubuntu/diaspora-install
Executable file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Install a fedora source package
|
||||||
|
#
|
||||||
|
# Usage diaspora-install <tar package>
|
||||||
|
|
||||||
|
test "$(perl -e 'print $>')" = "0" || {
|
||||||
|
echo "You need to be root to do this, giving up"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
getent group diaspora >/dev/null || groupadd -r diaspora
|
||||||
|
getent passwd diaspora >/dev/null || \
|
||||||
|
useradd -r -g diaspora \
|
||||||
|
-md /var/lib/diaspora \
|
||||||
|
-s /bin/bash \
|
||||||
|
-c "Diaspora daemon" diaspora
|
||||||
|
|
||||||
|
sudo tar -C /usr/share -xzf $1
|
||||||
|
|
||||||
|
cd /usr/share;
|
||||||
|
rm -rf /usr/share/diaspora
|
||||||
|
mv $( basename $1 .tar.gz) diaspora
|
||||||
|
cd /usr/share/diaspora
|
||||||
|
find . -perm /u+x -type f -exec \
|
||||||
|
sed -i 's|^#!/usr/local/bin/ruby|#!/usr/bin/ruby|' {} \; > /dev/null
|
||||||
|
rm -rf master/vendor/bundle master/public/uploads master/tmp master/log
|
||||||
|
sed -i '/BUNDLE_PATH/s|:.*|: /usr/lib/diaspora-bundle/bundle|' \
|
||||||
|
master/.bundle/config
|
||||||
|
|
||||||
|
cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS .
|
||||||
|
cp master/config/app_config.yml.example ./app_config.yml
|
||||||
|
cp master/pkg/ubuntu/diaspora-wsd /etc/init.d
|
||||||
|
|
||||||
|
sed -i '/^cd /s|.*|cd /usr/share/diaspora/master|' /etc/init.d/diaspora-wsd
|
||||||
|
|
||||||
|
cp master/pkg/ubuntu/diaspora.logrotate /etc/logrotate.d/diaspora
|
||||||
|
|
||||||
|
cp master/pkg/ubuntu/diaspora-setup .
|
||||||
|
|
||||||
|
mkdir -p /var/log/diaspora
|
||||||
|
mkdir -p /var/lib/diaspora/uploads
|
||||||
|
mkdir -p /var/lib/diaspora/tmp
|
||||||
|
mkdir -p /etc/diaspora
|
||||||
|
mkdir -p /usr/share/diaspora/master/pkg/ubuntu/dist
|
||||||
|
|
||||||
|
ln -sf /var/log/diaspora ./master/log
|
||||||
|
cp master/config/app_config.yml.example /etc/diaspora/app_config.yml
|
||||||
|
ln -sf /etc/diaspora/app_config.yml master/config/app_config.yml
|
||||||
|
ln -sf /var/lib/diaspora/uploads master/public/
|
||||||
|
ln -sf /var/lib/diaspora/tmp master
|
||||||
|
ln -sf /usr/lib/diaspora-bundle/bundle master/vendor
|
||||||
|
|
||||||
|
rm -rf /usr/share/doc/diaspora
|
||||||
|
mkdir -p /usr/share/doc/diaspora
|
||||||
|
mv AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT /usr/share/doc/diaspora
|
||||||
|
|
||||||
|
find ./ -print | xargs chown root:root
|
||||||
|
rm -rf /usr/share/doc/diaspora
|
||||||
|
mkdir /usr/share/doc/diaspora
|
||||||
|
|
||||||
|
chown diaspora:diaspora /usr/share/diaspora/master/config.ru
|
||||||
|
chown diaspora:diaspora /usr/share/diaspora/master/config/environment.rb
|
||||||
|
chown diaspora:diaspora /var/log/diaspora
|
||||||
|
chown diaspora:diaspora /var/lib/diaspora/uploads
|
||||||
|
chown diaspora:diaspora /var/lib/diaspora/tmp
|
||||||
|
chown diaspora:diaspora /var/lib/diaspora
|
||||||
|
chown diaspora:diaspora /usr/share/diaspora/master/pkg/ubuntu/dist
|
||||||
|
|
||||||
22
pkg/ubuntu/diaspora-install-deps
Executable file
22
pkg/ubuntu/diaspora-install-deps
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Install diaspora dependencies i. e., what apt-get will do
|
||||||
|
#
|
||||||
|
|
||||||
|
grep -v '^#' /etc/apt/sources.list | grep -q universe || {
|
||||||
|
cat <<- EOF
|
||||||
|
"Warning: it looks like you have not enabled universe in your
|
||||||
|
/etc/apt/sources.list. Most likely, this means trouble.
|
||||||
|
But I will try anyway.
|
||||||
|
EOF
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -qy --ignore-missing build-essential libxslt1-dev \
|
||||||
|
libxml2 ruby-full mongodb rake python-software-properties git-core \
|
||||||
|
imagemagick libmagick9-dev xulrunner-1.9
|
||||||
|
sudo add-apt-repository ppa:maco.m/ruby
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -qy rubygems
|
||||||
|
sudo gem install bundler --bindir /usr/local/bin
|
||||||
12
pkg/ubuntu/diaspora-reset
Executable file
12
pkg/ubuntu/diaspora-reset
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Try to revert to pristine state, deleting all users and
|
||||||
|
# configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
set -x
|
||||||
|
service mongodb stop
|
||||||
|
rm -rf /var/lib/mongodb/*
|
||||||
|
cp /usr/share/diaspora/master/config/app_config.yml.example \
|
||||||
|
/usr/share/diaspora/master/config/app_config.yml
|
||||||
|
service mongodb start
|
||||||
57
pkg/ubuntu/diaspora-setup
Executable file
57
pkg/ubuntu/diaspora-setup
Executable file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Do what's needed to initiate diaspora.
|
||||||
|
#
|
||||||
|
|
||||||
|
test "$( perl -e 'print $<')" = "0" || {
|
||||||
|
echo "You need to be root to do this, giving up"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
services=$( netstat -nl | grep '[^:]:3000[ \t]')
|
||||||
|
test -n "$services" && {
|
||||||
|
echo "Warning: something is already using port 3000"
|
||||||
|
echo " $services"
|
||||||
|
}
|
||||||
|
|
||||||
|
service mongodb stop || :
|
||||||
|
rm -f /var/lib/mongodb/mongod.lock
|
||||||
|
service mongodb start || :
|
||||||
|
|
||||||
|
cd /usr/share/diaspora/master
|
||||||
|
|
||||||
|
test -e config/app_config.yml ||
|
||||||
|
cp config/app_config.yml.example config/app_config.yml
|
||||||
|
|
||||||
|
if rake db:seed:dev; then
|
||||||
|
echo "Database config OK, new user tom/evankorth in place"
|
||||||
|
else
|
||||||
|
cat <<- EOF
|
||||||
|
|
||||||
|
Database config failed. You might want to
|
||||||
|
- Just remove the db lock file: rm /var/lib/mongodb/mongod.lock
|
||||||
|
- Remove all db files: rm -rf /var/lib/mongodb/*
|
||||||
|
- Reset the config file by
|
||||||
|
cp config/app_config.yml.example config/app_config.yml
|
||||||
|
Also, make sure the mongodb server is running e. g., using
|
||||||
|
'service mongod status'.
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 777 /var/lib/diaspora/uploads
|
||||||
|
chown -R diaspora /var/log/diaspora
|
||||||
|
|
||||||
|
hostname=$( awk '/pod_url:/ { print $2; exit }' <config/app_config.yml)
|
||||||
|
while : ; do
|
||||||
|
echo "Current hostname is \"$hostname\""
|
||||||
|
echo -n "Enter new hostname [$hostname] :"
|
||||||
|
read new_hostname garbage
|
||||||
|
echo -n "Use hostname \"$new_hostname\" as pod_url (Yes/No) [Yes]? :"
|
||||||
|
read yesno garbage
|
||||||
|
test "${yesno:0:1}" = 'y' -o "${yesno:0:1}" = 'Y' -o -z "$yesno" && {
|
||||||
|
sed -i "/pod_url:/s/$hostname/$new_hostname/g" config/app_config.yml &&
|
||||||
|
echo "config/app_config.yml updated."
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
102
pkg/ubuntu/diaspora-wsd
Executable file
102
pkg/ubuntu/diaspora-wsd
Executable file
|
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.d/init.d/diaspora-wsd
|
||||||
|
#
|
||||||
|
# SHOULD start the diaspora websocket daemon, but it doesn't. No way.
|
||||||
|
#
|
||||||
|
# chkconfig: - 80 80
|
||||||
|
# description: Diaspora websocket daemon
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: diaspora-wsd
|
||||||
|
# Required-Start: $local_fs $network
|
||||||
|
# Required-Stop: $local_fs $network
|
||||||
|
# Should-Start: $remote_fs
|
||||||
|
# Should-Stop: $remote_fs
|
||||||
|
# Default-Start:
|
||||||
|
# Default-Stop: 0 1 2 3 4 5 6
|
||||||
|
# Short-Description: start and stop Diaspora websocket server
|
||||||
|
# Description: The websocket server provides websocket services for
|
||||||
|
# diaspora.
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Source function library.
|
||||||
|
. /etc/init.d/functions
|
||||||
|
|
||||||
|
if [ -f /etc/sysconfig/diaspora-wsd -a $UID -eq 0 ]; then
|
||||||
|
. /etc/sysconfig/diaspora-wsd
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Note: this line is patched by installation scripts.
|
||||||
|
cd /usr/share/diaspora
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
prog="Diaspora websocket server"
|
||||||
|
exec="script/websocket_server.rb"
|
||||||
|
pidfile="/var/run/diaspora-wsd"
|
||||||
|
lockfile="/var/lock/subsys/diaspora-wsd"
|
||||||
|
logfile=/var/log/diaspora-wsd.log
|
||||||
|
|
||||||
|
[ -n "$OPTIONS" ] && OPTIONS=" $OPTIONS"
|
||||||
|
ruby_cmd="ruby -C $PWD $exec$OPTIONS"
|
||||||
|
|
||||||
|
start() {
|
||||||
|
[ $UID -eq 0 ] || exit 4
|
||||||
|
[ -f $exec ] || exit 5
|
||||||
|
|
||||||
|
echo -n $"Starting $prog: "
|
||||||
|
daemon --pidfile $pidfile "$ruby_cmd >>$logfile 2>&1 &"
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
if test $RETVAL = 0; then
|
||||||
|
touch $lockfile
|
||||||
|
pgrep -f "$ruby_cmd" > $pidfile || {
|
||||||
|
echo "Warning: cannot find running diaspora-webserver"
|
||||||
|
exit 7
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
[ $UID -eq 0 ] || exit 4
|
||||||
|
echo -n $"Stopping $prog: "
|
||||||
|
killproc -p $pidfile $exec
|
||||||
|
RETVAL=$?
|
||||||
|
[ $RETVAL -eq 0 ] && rm -f $lockfile
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# See how we were called.
|
||||||
|
#
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
force-reload|restart)
|
||||||
|
stop
|
||||||
|
sleep 1
|
||||||
|
start
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
condrestart|try-restart)
|
||||||
|
if [ -f $lockfile ]; then
|
||||||
|
stop
|
||||||
|
sleep 3
|
||||||
|
start
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status -p $pidfile $exec
|
||||||
|
RETVAL=$?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {condrestart|try-restart|start|stop|restart|force-reload|status}"
|
||||||
|
RETVAL=2
|
||||||
|
[ "$1" = 'usage' ] && RETVAL=0
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $RETVAL
|
||||||
13
pkg/ubuntu/diaspora.logrotate
Normal file
13
pkg/ubuntu/diaspora.logrotate
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
/var/log/diaspora/*.log {
|
||||||
|
create 755 diaspora diaspora
|
||||||
|
weekly
|
||||||
|
rotate 10
|
||||||
|
copytruncate
|
||||||
|
delaycompress
|
||||||
|
compress
|
||||||
|
notifempty
|
||||||
|
missingok
|
||||||
|
postrotate
|
||||||
|
( /sbin/service diaspora-wsd condrestart ) >/dev/null 2>&1
|
||||||
|
endscript
|
||||||
|
}
|
||||||
1
pkg/ubuntu/make-dist.sh
Symbolic link
1
pkg/ubuntu/make-dist.sh
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../fedora/make-dist.sh
|
||||||
|
|
@ -195,8 +195,8 @@ li.message {
|
||||||
li.message .content .from a {
|
li.message .content .from a {
|
||||||
font-weight: bold; }
|
font-weight: bold; }
|
||||||
li.message .content div.info {
|
li.message .content div.info {
|
||||||
color: #eeeeee;
|
color: #444444;
|
||||||
font-size: 11px; }
|
font-size: 13px; }
|
||||||
li.message .content div.info a {
|
li.message .content div.info a {
|
||||||
color: #cccccc; }
|
color: #cccccc; }
|
||||||
li.message .content div.info .time {
|
li.message .content div.info .time {
|
||||||
|
|
|
||||||
|
|
@ -266,8 +266,8 @@ li.message
|
||||||
:size 14px
|
:size 14px
|
||||||
|
|
||||||
div.info
|
div.info
|
||||||
:color #eee
|
:color #444
|
||||||
:font-size 11px
|
:font-size 13px
|
||||||
a
|
a
|
||||||
:color #ccc
|
:color #ccc
|
||||||
.time
|
.time
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Start diaspora websocket and main services
|
||||||
|
#
|
||||||
|
|
||||||
|
# Is someone listening on 3000 already? (ipv4 only test ?)
|
||||||
|
services=$( netstat -nl | grep '[^:]:3000[ \t]')
|
||||||
|
test -n "$services" && {
|
||||||
|
echo "Warning: something is already using port 3000"
|
||||||
|
echo " $services"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Check if Mongo is running
|
# Check if Mongo is running
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ describe Diaspora::Parser do
|
||||||
xml = retraction.to_diaspora_xml
|
xml = retraction.to_diaspora_xml
|
||||||
|
|
||||||
StatusMessage.count.should == 1
|
StatusMessage.count.should == 1
|
||||||
@user.receive xml
|
@user.receive xml, person
|
||||||
StatusMessage.count.should == 0
|
StatusMessage.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ describe Diaspora::Parser do
|
||||||
@user3.destroy
|
@user3.destroy
|
||||||
@person.destroy
|
@person.destroy
|
||||||
Person.all.count.should == person_count -1
|
Person.all.count.should == person_count -1
|
||||||
@user.receive xml
|
@user.receive xml, @person
|
||||||
Person.all.count.should == person_count
|
Person.all.count.should == person_count
|
||||||
|
|
||||||
Person.first(:_id => original_person_id).serialized_public_key.include?("PUBLIC").should be true
|
Person.first(:_id => original_person_id).serialized_public_key.include?("PUBLIC").should be true
|
||||||
|
|
@ -85,7 +85,7 @@ describe Diaspora::Parser do
|
||||||
xml = request.to_diaspora_xml
|
xml = request.to_diaspora_xml
|
||||||
|
|
||||||
Person.all.count.should be person_count
|
Person.all.count.should be person_count
|
||||||
@user.receive xml
|
@user.receive xml, @user2.person
|
||||||
Person.all.count.should be person_count
|
Person.all.count.should be person_count
|
||||||
|
|
||||||
@user2.reload
|
@user2.reload
|
||||||
|
|
@ -106,7 +106,7 @@ describe Diaspora::Parser do
|
||||||
@user2.person.destroy
|
@user2.person.destroy
|
||||||
@user2.destroy
|
@user2.destroy
|
||||||
|
|
||||||
@user.receive xml
|
@user.receive xml, @user2.person
|
||||||
new_person = Person.first(:url => @user2.person.url)
|
new_person = Person.first(:url => @user2.person.url)
|
||||||
new_person.nil?.should be false
|
new_person.nil?.should be false
|
||||||
|
|
||||||
|
|
@ -128,14 +128,16 @@ describe Diaspora::Parser do
|
||||||
|
|
||||||
@user2.person.destroy
|
@user2.person.destroy
|
||||||
@user2.destroy
|
@user2.destroy
|
||||||
@user.receive xml
|
@user.receive xml, @user2.person
|
||||||
|
|
||||||
|
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
aspect_people_count = @aspect.people.size
|
aspect_people_count = @aspect.people.size
|
||||||
#They are now friends
|
#They are now friends
|
||||||
|
|
||||||
Person.count.should == person_count
|
Person.count.should == person_count
|
||||||
@user.receive retraction_xml
|
@user.receive retraction_xml, @user2.person
|
||||||
|
|
||||||
|
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
@aspect.people.size.should == aspect_people_count -1
|
@aspect.people.size.should == aspect_people_count -1
|
||||||
|
|
@ -163,7 +165,7 @@ describe Diaspora::Parser do
|
||||||
old_profile.first_name.should == 'bob'
|
old_profile.first_name.should == 'bob'
|
||||||
|
|
||||||
#Marshal profile
|
#Marshal profile
|
||||||
@user.receive xml
|
@user.receive xml, person
|
||||||
|
|
||||||
#Check that marshaled profile is the same as old profile
|
#Check that marshaled profile is the same as old profile
|
||||||
person = Person.first(:id => person.id)
|
person = Person.first(:id => person.id)
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ describe Aspect do
|
||||||
|
|
||||||
message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
|
message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
|
||||||
|
|
||||||
@user.receive message.to_diaspora_xml
|
@user.receive message.to_diaspora_xml, @user2.person
|
||||||
|
|
||||||
aspect.reload
|
aspect.reload
|
||||||
aspect.posts.include?(message).should be true
|
aspect.posts.include?(message).should be true
|
||||||
|
|
@ -100,13 +100,14 @@ describe Aspect do
|
||||||
|
|
||||||
message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
|
message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
|
||||||
|
|
||||||
@user.receive message.to_diaspora_xml
|
@user.receive message.to_diaspora_xml, @user2.person
|
||||||
aspect.reload
|
aspect.reload
|
||||||
|
|
||||||
aspect.post_ids.include?(message.id).should be true
|
aspect.post_ids.include?(message.id).should be true
|
||||||
|
|
||||||
retraction = @user2.retract(message)
|
retraction = @user2.retract(message)
|
||||||
@user.receive retraction.to_diaspora_xml
|
@user.receive retraction.to_diaspora_xml, @user2.person
|
||||||
|
|
||||||
|
|
||||||
aspect.reload
|
aspect.reload
|
||||||
aspect.post_ids.include?(message.id).should be false
|
aspect.post_ids.include?(message.id).should be false
|
||||||
|
|
@ -151,7 +152,7 @@ describe Aspect do
|
||||||
it 'should move all the by that user to the new aspect' do
|
it 'should move all the by that user to the new aspect' do
|
||||||
message = @user2.post(:status_message, :message => "Hey Dude", :to => @aspect2.id)
|
message = @user2.post(:status_message, :message => "Hey Dude", :to => @aspect2.id)
|
||||||
|
|
||||||
@user.receive message.to_diaspora_xml
|
@user.receive message.to_diaspora_xml, @user2.person
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
|
|
||||||
@aspect.posts.count.should == 1
|
@aspect.posts.count.should == 1
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,30 @@ describe Comment do
|
||||||
@user.reload
|
@user.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should receive a comment from a person not on the pod' do
|
||||||
|
user3 = Factory.create :user
|
||||||
|
aspect3 = user3.aspect(:name => "blah")
|
||||||
|
|
||||||
|
friend_users(@user, @aspect, user3, aspect3)
|
||||||
|
|
||||||
|
comment = Comment.new(:person_id => user3.person.id, :text => "hey", :post => @user_status)
|
||||||
|
comment.creator_signature = comment.sign_with_key(user3.encryption_key)
|
||||||
|
|
||||||
|
|
||||||
|
comment.post_creator_signature = comment.sign_with_key(@user.encryption_key)
|
||||||
|
xml = @user.salmon(comment).xml_for(@user2)
|
||||||
|
|
||||||
|
user3.person.delete
|
||||||
|
user3.delete
|
||||||
|
|
||||||
|
|
||||||
|
@user_status.reload
|
||||||
|
@user_status.comments.should == []
|
||||||
|
@user2.receive_salmon(xml)
|
||||||
|
@user_status.reload
|
||||||
|
@user_status.comments.include?(comment).should be true
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have the post in the aspects post list' do
|
it 'should have the post in the aspects post list' do
|
||||||
aspect = Aspect.first(:id => @aspect.id)
|
aspect = Aspect.first(:id => @aspect.id)
|
||||||
aspect.people.size.should == 2
|
aspect.people.size.should == 2
|
||||||
|
|
@ -73,33 +97,33 @@ describe Comment do
|
||||||
it 'should send a comment a person made on your post to all people' do
|
it 'should send a comment a person made on your post to all people' do
|
||||||
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
|
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
|
||||||
User::QUEUE.should_receive(:add_post_request).twice
|
User::QUEUE.should_receive(:add_post_request).twice
|
||||||
@user.receive(comment.to_diaspora_xml)
|
@user.receive comment.to_diaspora_xml, @person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should send a comment a user made on your post to all people' do
|
it 'should send a comment a user made on your post to all people' do
|
||||||
|
|
||||||
comment = @user2.comment( "balls", :on => @user_status)
|
comment = @user2.comment( "balls", :on => @user_status)
|
||||||
User::QUEUE.should_receive(:add_post_request).twice
|
User::QUEUE.should_receive(:add_post_request).twice
|
||||||
@user.receive(comment.to_diaspora_xml)
|
@user.receive comment.to_diaspora_xml, @user2.person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not send a comment a person made on his own post to anyone' do
|
it 'should not send a comment a person made on his own post to anyone' do
|
||||||
User::QUEUE.should_not_receive(:add_post_request)
|
User::QUEUE.should_not_receive(:add_post_request)
|
||||||
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status)
|
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status)
|
||||||
@user.receive(comment.to_diaspora_xml)
|
@user.receive comment.to_diaspora_xml, @person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not send a comment a person made on a person post to anyone' do
|
it 'should not send a comment a person made on a person post to anyone' do
|
||||||
User::QUEUE.should_not_receive(:add_post_request)
|
User::QUEUE.should_not_receive(:add_post_request)
|
||||||
comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status)
|
comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status)
|
||||||
@user.receive(comment.to_diaspora_xml)
|
@user.receive comment.to_diaspora_xml, @person
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not clear the aspect post array on receiving a comment' do
|
it 'should not clear the aspect post array on receiving a comment' do
|
||||||
@aspect.post_ids.include?(@user_status.id).should be true
|
@aspect.post_ids.include?(@user_status.id).should be true
|
||||||
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
|
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
|
||||||
|
|
||||||
@user.receive(comment.to_diaspora_xml)
|
@user.receive comment.to_diaspora_xml, @person
|
||||||
|
|
||||||
@aspect.reload
|
@aspect.reload
|
||||||
@aspect.post_ids.include?(@user_status.id).should be true
|
@aspect.post_ids.include?(@user_status.id).should be true
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ describe Person do
|
||||||
|
|
||||||
it 'should have a profile in its xml' do
|
it 'should have a profile in its xml' do
|
||||||
@xml.include?("first_name").should == true
|
@xml.include?("first_name").should == true
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -54,7 +55,7 @@ describe Person do
|
||||||
person_two.owns?(person_message).should be false
|
person_two.owns?(person_message).should be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should delete all of user except comments upon user deletion' do
|
it 'should delete all of user posts except comments upon user deletion' do
|
||||||
person = Factory.create(:person)
|
person = Factory.create(:person)
|
||||||
|
|
||||||
Factory.create(:status_message, :person => person)
|
Factory.create(:status_message, :person => person)
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ describe Photo do
|
||||||
id = @photo.id
|
id = @photo.id
|
||||||
|
|
||||||
@photo.destroy
|
@photo.destroy
|
||||||
@user.receive xml
|
@user.receive xml, @photo.person
|
||||||
|
|
||||||
new_photo = Photo.first(:id => id)
|
new_photo = Photo.first(:id => id)
|
||||||
new_photo.url.nil?.should be false
|
new_photo.url.nil?.should be false
|
||||||
|
|
|
||||||
|
|
@ -28,38 +28,35 @@ describe User do
|
||||||
user.raw_visible_posts.count.should be 1
|
user.raw_visible_posts.count.should be 1
|
||||||
|
|
||||||
malicious_message = Factory.build( :status_message, :id => original_message.id, :message => 'BAD!!!', :person => user3.person)
|
malicious_message = Factory.build( :status_message, :id => original_message.id, :message => 'BAD!!!', :person => user3.person)
|
||||||
user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person))
|
proc{user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person))}.should raise_error /Malicious Post/
|
||||||
|
|
||||||
user.raw_visible_posts.count.should be 1
|
user.raw_visible_posts.count.should be 1
|
||||||
user.raw_visible_posts.first.message.should == "store this!"
|
user.raw_visible_posts.first.message.should == "store this!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ovewrites messages which apear to ' do
|
it 'ovewrites messages which apear to be from the same user' do
|
||||||
original_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id
|
original_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id
|
||||||
user.receive_salmon(user2.salmon(original_message).xml_for(user.person))
|
user.receive_salmon(user2.salmon(original_message).xml_for(user.person))
|
||||||
user.raw_visible_posts.count.should be 1
|
user.raw_visible_posts.count.should be 1
|
||||||
|
|
||||||
malicious_message = Factory.build( :status_message, :id => original_message.id, :message => 'BAD!!!', :person => user2.person)
|
malicious_message = Factory.build( :status_message, :id => original_message.id, :message => 'BAD!!!', :person => user2.person)
|
||||||
user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person))
|
proc{user.receive_salmon(user3.salmon(malicious_message).xml_for(user.person))}.should raise_error /Malicious Post/
|
||||||
|
|
||||||
|
|
||||||
user.raw_visible_posts.count.should be 1
|
user.raw_visible_posts.count.should be 1
|
||||||
user.raw_visible_posts.first.message.should == "store this!"
|
user.raw_visible_posts.first.message.should == "store this!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'overites another persons profile' do
|
it 'overites another persons profile' do
|
||||||
pending "don't allow profile overwriting"
|
|
||||||
profile = user2.profile.clone
|
profile = user2.profile.clone
|
||||||
profile.first_name = "Not BOB"
|
profile.first_name = "Not BOB"
|
||||||
|
|
||||||
user2.reload
|
user2.reload
|
||||||
user2.profile.first_name.should == "Robert"
|
user2.profile.first_name.should == "Robert"
|
||||||
user.receive_salmon(user3.salmon(profile).xml_for(user.person))
|
proc{user.receive_salmon(user3.salmon(profile).xml_for(user.person))}.should raise_error /Malicious Post/
|
||||||
user2.reload
|
user2.reload
|
||||||
user2.profile.first_name.should == "Robert"
|
user2.profile.first_name.should == "Robert"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'overwrites requests' do
|
|
||||||
pending
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ describe User do
|
||||||
user2.destroy
|
user2.destroy
|
||||||
status_message.destroy
|
status_message.destroy
|
||||||
StatusMessage.all.size.should == 0
|
StatusMessage.all.size.should == 0
|
||||||
user.receive( xml )
|
user.receive xml , user2.person
|
||||||
|
|
||||||
Post.all(:person_id => person.id).first.message.should == 'store this!'
|
Post.all(:person_id => person.id).first.message.should == 'store this!'
|
||||||
StatusMessage.all.size.should == 1
|
StatusMessage.all.size.should == 1
|
||||||
|
|
@ -40,7 +40,7 @@ describe User do
|
||||||
(0..5).each{ |n|
|
(0..5).each{ |n|
|
||||||
status_message = user2.post :status_message, :message => "store this #{n}!", :to => aspect2.id
|
status_message = user2.post :status_message, :message => "store this #{n}!", :to => aspect2.id
|
||||||
xml = status_message.to_diaspora_xml
|
xml = status_message.to_diaspora_xml
|
||||||
user.receive( xml )
|
user.receive xml, user2.person
|
||||||
}
|
}
|
||||||
|
|
||||||
user.aspects.size.should == num_aspects
|
user.aspects.size.should == num_aspects
|
||||||
|
|
@ -60,7 +60,7 @@ describe User do
|
||||||
|
|
||||||
it 'should be removed on unfriending' do
|
it 'should be removed on unfriending' do
|
||||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||||
user.receive status_message.to_diaspora_xml
|
user.receive status_message.to_diaspora_xml, user2.person
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
user.raw_visible_posts.count.should == 1
|
user.raw_visible_posts.count.should == 1
|
||||||
|
|
@ -75,7 +75,7 @@ describe User do
|
||||||
|
|
||||||
it 'should be remove a post if the noone links to it' do
|
it 'should be remove a post if the noone links to it' do
|
||||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||||
user.receive status_message.to_diaspora_xml
|
user.receive status_message.to_diaspora_xml, user2.person
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
user.raw_visible_posts.count.should == 1
|
user.raw_visible_posts.count.should == 1
|
||||||
|
|
@ -92,7 +92,7 @@ describe User do
|
||||||
|
|
||||||
it 'should keep track of user references for one person ' do
|
it 'should keep track of user references for one person ' do
|
||||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||||
user.receive status_message.to_diaspora_xml
|
user.receive status_message.to_diaspora_xml, user2.person
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
user.raw_visible_posts.count.should == 1
|
user.raw_visible_posts.count.should == 1
|
||||||
|
|
@ -116,9 +116,9 @@ describe User do
|
||||||
user3.activate_friend(user2.person, aspect3)
|
user3.activate_friend(user2.person, aspect3)
|
||||||
|
|
||||||
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
status_message = user2.post :status_message, :message => "hi", :to => aspect2.id
|
||||||
user.receive status_message.to_diaspora_xml
|
user.receive status_message.to_diaspora_xml, user2.person
|
||||||
|
|
||||||
user3.receive status_message.to_diaspora_xml
|
user3.receive status_message.to_diaspora_xml, user2.person
|
||||||
user.reload
|
user.reload
|
||||||
user3.reload
|
user3.reload
|
||||||
|
|
||||||
|
|
@ -145,11 +145,11 @@ describe User do
|
||||||
|
|
||||||
post = user.post :status_message, :message => "hello", :to => aspect.id
|
post = user.post :status_message, :message => "hello", :to => aspect.id
|
||||||
|
|
||||||
user2.receive post.to_diaspora_xml
|
user2.receive post.to_diaspora_xml, user.person
|
||||||
user3.receive post.to_diaspora_xml
|
user3.receive post.to_diaspora_xml, user.person
|
||||||
|
|
||||||
comment = user2.comment('tada',:on => post)
|
comment = user2.comment('tada',:on => post)
|
||||||
user.receive comment.to_diaspora_xml
|
user.receive comment.to_diaspora_xml, user2.person
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
commenter_id = user2.person.id
|
commenter_id = user2.person.id
|
||||||
|
|
@ -159,7 +159,7 @@ describe User do
|
||||||
comment_id = comment.id
|
comment_id = comment.id
|
||||||
|
|
||||||
comment.delete
|
comment.delete
|
||||||
user3.receive comment.to_diaspora_xml
|
user3.receive comment.to_diaspora_xml, user.person
|
||||||
user3.reload
|
user3.reload
|
||||||
|
|
||||||
new_comment = Comment.find_by_id(comment_id)
|
new_comment = Comment.find_by_id(comment_id)
|
||||||
|
|
|
||||||
|
|
@ -5,74 +5,69 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
before do
|
let(:user) {Factory.create :user}
|
||||||
@user = Factory.create(:user)
|
let(:aspect) {user.aspect(:name => 'heroes')}
|
||||||
@aspect = @user.aspect(:name => 'heroes')
|
let(:friend) { Factory.create(:person) }
|
||||||
end
|
|
||||||
|
|
||||||
describe 'friend requesting' do
|
let(:person_one) {Factory.create :person}
|
||||||
|
let(:person_two) {Factory.create :person}
|
||||||
|
|
||||||
|
let(:user2) { Factory.create :user}
|
||||||
|
let(:aspect2) { user2.aspect(:name => "aspect two")}
|
||||||
|
|
||||||
|
context 'friend requesting' do
|
||||||
it "should assign a request to a aspect" do
|
it "should assign a request to a aspect" do
|
||||||
friend = Factory.create(:person)
|
|
||||||
aspect = @user.aspect(:name => "Dudes")
|
|
||||||
aspect.requests.size.should == 0
|
aspect.requests.size.should == 0
|
||||||
|
|
||||||
@user.send_friend_request_to(friend, aspect)
|
user.send_friend_request_to(friend, aspect)
|
||||||
|
|
||||||
aspect.reload
|
aspect.reload
|
||||||
aspect.requests.size.should == 1
|
aspect.requests.size.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to accept a pending friend request" do
|
it "should be able to accept a pending friend request" do
|
||||||
friend = Factory.create(:person)
|
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||||
r = Request.instantiate(:to => @user.receive_url, :from => friend)
|
|
||||||
r.save
|
r.save
|
||||||
Person.all.count.should == 2
|
Person.all.count.should == 2
|
||||||
Request.for_user(@user).all.count.should == 1
|
Request.for_user(user).all.count.should == 1
|
||||||
@user.accept_friend_request(r.id, @aspect.id)
|
user.accept_friend_request(r.id, aspect.id)
|
||||||
Request.for_user(@user).all.count.should == 0
|
Request.for_user(user).all.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to ignore a pending friend request' do
|
it 'should be able to ignore a pending friend request' do
|
||||||
friend = Factory.create(:person)
|
friend = Factory.create(:person)
|
||||||
r = Request.instantiate(:to => @user.receive_url, :from => friend)
|
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||||
r.save
|
r.save
|
||||||
|
|
||||||
Person.count.should == 2
|
Person.count.should == 2
|
||||||
|
|
||||||
@user.ignore_friend_request(r.id)
|
user.ignore_friend_request(r.id)
|
||||||
|
|
||||||
Person.count.should == 2
|
Person.count.should == 2
|
||||||
Request.count.should == 0
|
Request.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be able to friend request an existing friend' do
|
it 'should not be able to friend request an existing friend' do
|
||||||
friend = Factory.create(:person)
|
user.friends << friend
|
||||||
|
user.save
|
||||||
|
|
||||||
@user.friends << friend
|
proc { user.send_friend_request_to(friend, aspect) }.should raise_error
|
||||||
@user.save
|
|
||||||
|
|
||||||
proc { @user.send_friend_request_to(friend, @aspect) }.should raise_error
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'multiple users accepting/rejecting the same person' do
|
describe 'multiple users accepting/rejecting the same person' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@person_one = Factory.create :person
|
user.pending_requests.empty?.should be true
|
||||||
@person_one.save
|
user.friends.empty?.should be true
|
||||||
|
user2.pending_requests.empty?.should be true
|
||||||
|
user2.friends.empty?.should be true
|
||||||
|
|
||||||
@user2 = Factory.create :user
|
@request = Request.instantiate(:to => user.receive_url, :from => person_one)
|
||||||
@aspect2 = @user2.aspect(:name => "aspect two")
|
@request_two = Request.instantiate(:to => user2.receive_url, :from => person_one)
|
||||||
|
@request_three = Request.instantiate(:to => user2.receive_url, :from => user.person)
|
||||||
|
|
||||||
@user.pending_requests.empty?.should be true
|
@req_xml = @request.to_diaspora_xml
|
||||||
@user.friends.empty?.should be true
|
@req_two_xml = @request_two.to_diaspora_xml
|
||||||
@user2.pending_requests.empty?.should be true
|
|
||||||
@user2.friends.empty?.should be true
|
|
||||||
|
|
||||||
@request = Request.instantiate(:to => @user.receive_url, :from => @person_one)
|
|
||||||
@request_two = Request.instantiate(:to => @user2.receive_url, :from => @person_one)
|
|
||||||
@request_three = Request.instantiate(:to => @user2.receive_url, :from => @user.person)
|
|
||||||
|
|
||||||
@req_xml = @request.to_diaspora_xml
|
|
||||||
@req_two_xml = @request_two.to_diaspora_xml
|
|
||||||
@req_three_xml = @request_three.to_diaspora_xml
|
@req_three_xml = @request_three.to_diaspora_xml
|
||||||
|
|
||||||
@request.destroy
|
@request.destroy
|
||||||
|
|
@ -81,129 +76,126 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should befriend the user other user on the same pod' do
|
it 'should befriend the user other user on the same pod' do
|
||||||
@user2.receive @req_three_xml
|
user2.receive @req_three_xml, user.person
|
||||||
@user2.pending_requests.size.should be 1
|
user2.pending_requests.size.should be 1
|
||||||
@user2.accept_friend_request @request_three.id, @aspect2.id
|
user2.accept_friend_request @request_three.id, aspect2.id
|
||||||
@user2.friends.include?(@user.person).should be true
|
user2.friends.include?(user.person).should be true
|
||||||
Person.all.count.should be 3
|
Person.all.count.should be 3
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not delete the ignored user on the same pod' do
|
it 'should not delete the ignored user on the same pod' do
|
||||||
@user2.receive @req_three_xml
|
user2.receive @req_three_xml, user.person
|
||||||
@user2.pending_requests.size.should be 1
|
user2.pending_requests.size.should be 1
|
||||||
@user2.ignore_friend_request @request_three.id
|
user2.ignore_friend_request @request_three.id
|
||||||
@user2.friends.include?(@user.person).should be false
|
user2.friends.include?(user.person).should be false
|
||||||
Person.all.count.should be 3
|
Person.all.count.should be 3
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should both users should befriend the same person' do
|
it 'should both users should befriend the same person' do
|
||||||
@user.receive @req_xml
|
user.receive @req_xml, person_one
|
||||||
@user.pending_requests.size.should be 1
|
user.pending_requests.size.should be 1
|
||||||
@user.accept_friend_request @request.id, @aspect.id
|
user.accept_friend_request @request.id, aspect.id
|
||||||
@user.friends.include?(@person_one).should be true
|
user.friends.include?(person_one).should be true
|
||||||
|
|
||||||
@user2.receive @req_two_xml
|
user2.receive @req_two_xml, person_one
|
||||||
@user2.pending_requests.size.should be 1
|
user2.pending_requests.size.should be 1
|
||||||
@user2.accept_friend_request @request_two.id, @aspect2.id
|
user2.accept_friend_request @request_two.id, aspect2.id
|
||||||
@user2.friends.include?(@person_one).should be true
|
user2.friends.include?(person_one).should be true
|
||||||
Person.all.count.should be 3
|
Person.all.count.should be 3
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should keep the person around if one of the users rejects him' do
|
it 'should keep the person around if one of the users rejects him' do
|
||||||
@user.receive @req_xml
|
user.receive @req_xml, person_one
|
||||||
@user.pending_requests.size.should be 1
|
user.pending_requests.size.should be 1
|
||||||
@user.accept_friend_request @request.id, @aspect.id
|
user.accept_friend_request @request.id, aspect.id
|
||||||
@user.friends.include?(@person_one).should be true
|
user.friends.include?(person_one).should be true
|
||||||
|
|
||||||
@user2.receive @req_two_xml
|
user2.receive @req_two_xml, person_one
|
||||||
@user2.pending_requests.size.should be 1
|
user2.pending_requests.size.should be 1
|
||||||
@user2.ignore_friend_request @request_two.id
|
user2.ignore_friend_request @request_two.id
|
||||||
@user2.friends.include?(@person_one).should be false
|
user2.friends.include?(person_one).should be false
|
||||||
Person.all.count.should be 3
|
Person.all.count.should be 3
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should keep the person around if the users ignores them' do
|
it 'should keep the person around if the users ignores them' do
|
||||||
@user.receive @req_xml
|
user.receive @req_xml, person_one
|
||||||
@user.pending_requests.size.should be 1
|
user.pending_requests.size.should be 1
|
||||||
@user.ignore_friend_request @user.pending_requests.first.id
|
user.ignore_friend_request user.pending_requests.first.id
|
||||||
@user.friends.include?(@person_one).should be false
|
user.friends.include?(person_one).should be false
|
||||||
|
|
||||||
@user2.receive @req_two_xml
|
user2.receive @req_two_xml, person_one
|
||||||
@user2.pending_requests.size.should be 1
|
user2.pending_requests.size.should be 1
|
||||||
@user2.ignore_friend_request @user2.pending_requests.first.id #@request_two.id
|
user2.ignore_friend_request user2.pending_requests.first.id #@request_two.id
|
||||||
@user2.friends.include?(@person_one).should be false
|
user2.friends.include?(person_one).should be false
|
||||||
Person.all.count.should be 3
|
Person.all.count.should be 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'a user accepting rejecting multiple people' do
|
describe 'a user accepting rejecting multiple people' do
|
||||||
before do
|
before do
|
||||||
@person_one = Factory.create :person
|
user.pending_requests.empty?.should be true
|
||||||
@person_two = Factory.create :person
|
user.friends.empty?.should be true
|
||||||
|
|
||||||
@user.pending_requests.empty?.should be true
|
@request = Request.instantiate(:to => user.receive_url, :from => person_one)
|
||||||
@user.friends.empty?.should be true
|
@request_two = Request.instantiate(:to => user.receive_url, :from => person_two)
|
||||||
|
|
||||||
@request = Request.instantiate(:to => @user.receive_url, :from => @person_one)
|
|
||||||
@request_two = Request.instantiate(:to => @user.receive_url, :from => @person_two)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "keeps the right counts of friends" do
|
it "keeps the right counts of friends" do
|
||||||
@user.receive_friend_request @request
|
user.receive_friend_request @request
|
||||||
|
|
||||||
@person_two.destroy
|
person_two.destroy
|
||||||
@user.pending_requests.size.should be 1
|
user.pending_requests.size.should be 1
|
||||||
@user.friends.size.should be 0
|
user.friends.size.should be 0
|
||||||
|
|
||||||
@user.receive_friend_request @request_two
|
user.receive_friend_request @request_two
|
||||||
@user.pending_requests.size.should be 2
|
user.pending_requests.size.should be 2
|
||||||
@user.friends.size.should be 0
|
user.friends.size.should be 0
|
||||||
|
|
||||||
@user.accept_friend_request @request.id, @aspect.id
|
user.accept_friend_request @request.id, aspect.id
|
||||||
@user.pending_requests.size.should be 1
|
user.pending_requests.size.should be 1
|
||||||
@user.friends.size.should be 1
|
user.friends.size.should be 1
|
||||||
@user.friends.include?(@person_one).should be true
|
user.friends.include?(person_one).should be true
|
||||||
|
|
||||||
@user.ignore_friend_request @request_two.id
|
user.ignore_friend_request @request_two.id
|
||||||
@user.pending_requests.size.should be 0
|
user.pending_requests.size.should be 0
|
||||||
@user.friends.size.should be 1
|
user.friends.size.should be 1
|
||||||
@user.friends.include?(@person_two).should be false
|
user.friends.include?(person_two).should be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'unfriending' do
|
describe 'unfriending' do
|
||||||
before do
|
before do
|
||||||
@user2 = Factory.create :user
|
friend_users(user,aspect, user2, aspect2)
|
||||||
@aspect2 = @user2.aspect(:name => "Gross people")
|
user.reload
|
||||||
|
user2.reload
|
||||||
friend_users(@user, @aspect, @user2, @aspect2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unfriend the other user on the same seed' do
|
it 'should unfriend the other user on the same seed' do
|
||||||
@user.friends(true).count.should == 1
|
user.friends.count.should == 1
|
||||||
@user2.friends(true).count.should == 1
|
user2.friends.count.should == 1
|
||||||
|
|
||||||
@user2.unfriend @user.person
|
user2.unfriend user.person
|
||||||
|
user2.reload
|
||||||
|
|
||||||
@user2.friends(true).count.should == 0
|
user2.friends.count.should == 0
|
||||||
@user.unfriended_by @user2.person
|
user.unfriended_by user2.person
|
||||||
|
|
||||||
@aspect.reload.people(true).count.should == 0
|
aspect.reload.people.count.should == 0
|
||||||
@aspect2.reload.people(true).count.should == 0
|
aspect2.reload.people.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a post' do
|
context 'with a post' do
|
||||||
before do
|
before do
|
||||||
@message = @user.post(:status_message, :message => "hi", :to => @aspect.id)
|
@message = user.post(:status_message, :message => "hi", :to => aspect.id)
|
||||||
@user2.receive @message.to_diaspora_xml.to_s
|
user2.receive @message.to_diaspora_xml.to_s, user.person
|
||||||
@user2.unfriend @user.person
|
user2.unfriend user.person
|
||||||
@user.unfriended_by @user2.person
|
user.unfriended_by user2.person
|
||||||
end
|
end
|
||||||
it "deletes the unfriended user's posts from visible_posts" do
|
it "deletes the unfriended user's posts from visible_posts" do
|
||||||
@user.raw_visible_posts(true).include?(@message.id).should be_false
|
user.reload.raw_visible_posts.include?(@message.id).should be_false
|
||||||
end
|
end
|
||||||
it "deletes the unfriended user's posts from the aspect's posts" do
|
it "deletes the unfriended user's posts from the aspect's posts" do
|
||||||
@aspect2.posts(true).include?(@message).should be_false
|
aspect2.posts.include?(@message).should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,15 @@ describe User do
|
||||||
let!(:second_aspect) { user.aspect(:name => 'losers') }
|
let!(:second_aspect) { user.aspect(:name => 'losers') }
|
||||||
|
|
||||||
let!(:user2) { Factory(:user_with_aspect) }
|
let!(:user2) { Factory(:user_with_aspect) }
|
||||||
|
let!(:user3) { Factory(:user_with_aspect) }
|
||||||
|
let!(:user4) { Factory(:user_with_aspect) }
|
||||||
|
|
||||||
let!(:status_message1) { user2.post :status_message, :message => "hi", :to => user2.aspects.first.id }
|
let!(:status_message1) { user2.post :status_message, :message => "hi", :to => user2.aspects.first.id }
|
||||||
let!(:status_message2) { user2.post :status_message, :message => "hey", :public => true , :to => user2.aspects.first.id }
|
let!(:status_message2) { user2.post :status_message, :message => "hey", :public => true , :to => user2.aspects.first.id }
|
||||||
let!(:status_message3) { user2.post :status_message, :message => "va", :to => user2.aspects.first.id }
|
let!(:status_message3) { user2.post :status_message, :message => "va", :to => user2.aspects.first.id }
|
||||||
let!(:status_message4) { user2.post :status_message, :message => "da", :public => true , :to => user2.aspects.first.id }
|
let!(:status_message4) { user2.post :status_message, :message => "da", :public => true , :to => user2.aspects.first.id }
|
||||||
|
let!(:status_message5) { user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id}
|
||||||
|
let!(:status_message6) { user4.post :status_message, :message => "yooo", :to => user4.aspects.first.id}
|
||||||
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
@ -44,20 +48,15 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "queries by aspect" do
|
it "queries by aspect" do
|
||||||
user3 = Factory(:user_with_aspect)
|
|
||||||
status_message2 = user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id
|
|
||||||
user4 = Factory(:user_with_aspect)
|
|
||||||
status_message3 = user4.post :status_message, :message => "yooo", :to => user4.aspects.first.id
|
|
||||||
|
|
||||||
friend_users(user, second_aspect, user3, user3.aspects.first)
|
friend_users(user, second_aspect, user3, user3.aspects.first)
|
||||||
friend_users(user, second_aspect, user4, user4.aspects.first)
|
friend_users(user, second_aspect, user4, user4.aspects.first)
|
||||||
|
|
||||||
user.receive status_message1.to_diaspora_xml
|
user.receive status_message4.to_diaspora_xml, user2.person
|
||||||
user.receive status_message2.to_diaspora_xml
|
user.receive status_message5.to_diaspora_xml, user3.person
|
||||||
user.receive status_message3.to_diaspora_xml
|
user.receive status_message6.to_diaspora_xml, user4.person
|
||||||
|
|
||||||
user.visible_posts(:by_members_of => first_aspect).should =~ [status_message1]
|
user.visible_posts(:by_members_of => first_aspect).should =~ [status_message4]
|
||||||
user.visible_posts(:by_members_of => second_aspect).should =~ [status_message2, status_message3]
|
user.visible_posts(:by_members_of => second_aspect).should =~ [status_message5, status_message6]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ ImageUploader.enable_processing = false
|
||||||
request = user1.send_friend_request_to(user2.person, aspect1)
|
request = user1.send_friend_request_to(user2.person, aspect1)
|
||||||
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
|
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
|
||||||
user1.reload
|
user1.reload
|
||||||
user1.receive reversed_request.to_diaspora_xml
|
user1.receive reversed_request.to_diaspora_xml, user2.person
|
||||||
user1.reload
|
user1.reload
|
||||||
aspect1.reload
|
aspect1.reload
|
||||||
user2.reload
|
user2.reload
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@ describe 'user encryption' do
|
||||||
|
|
||||||
xml = request.to_diaspora_xml
|
xml = request.to_diaspora_xml
|
||||||
|
|
||||||
remote_user.person.destroy
|
remote_user.person.delete
|
||||||
remote_user.destroy
|
remote_user.delete
|
||||||
|
|
||||||
person_count = Person.all.count
|
person_count = Person.all.count
|
||||||
proc {@user.receive xml}.should_not raise_error /ignature was not valid/
|
@user.receive xml, remote_user.person
|
||||||
|
|
||||||
Person.all.count.should == person_count + 1
|
Person.all.count.should == person_count + 1
|
||||||
new_person = Person.first(:id => id)
|
new_person = Person.first(:id => id)
|
||||||
new_person.exported_key.should == original_key
|
new_person.exported_key.should == original_key
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue