Commit ac1866da72c9397014421883b300c8cee68a604e
Exists in
staging
and in
4 other branches
Merge branch 'api' into production
Showing
1 changed file
with
9 additions
and
5 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
... | ... | @@ -39,12 +39,16 @@ module Noosfero |
39 | 39 | desc "Add a follower for the article" |
40 | 40 | post ':id/follow' do |
41 | 41 | article = find_article(environment.articles, params[:id]) |
42 | - article_follower = ArticleFollower.new | |
43 | - article_follower.article = article | |
44 | - article_follower.person = current_person | |
45 | - article_follower.save! | |
42 | + if article.article_followers.include?(current_person) | |
43 | + {:success => false, :already_follow => true} | |
44 | + else | |
45 | + article_follower = ArticleFollower.new | |
46 | + article_follower.article = article | |
47 | + article_follower.person = current_person | |
48 | + article_follower.save! | |
49 | + {:success => true} | |
50 | + end | |
46 | 51 | end |
47 | - | |
48 | 52 | |
49 | 53 | post ':id/vote' do |
50 | 54 | value = (params[:value] || 1).to_i | ... | ... |