Commit c279721d48ee70de18a9850a295533202c057d8b

Authored by Caio Almeida
1 parent 268ebd86

API: Adding report abuse support for articles

lib/noosfero/api/v1/articles.rb
... ... @@ -28,6 +28,35 @@ module Noosfero
28 28 article = find_article(environment.articles, params[:id])
29 29 present article, :with => Entities::Article, :fields => params[:fields]
30 30 end
  31 +
  32 + post ':id/report_abuse' do
  33 + article = find_article(environment.articles, params[:id])
  34 + profile = article.profile
  35 + begin
  36 + abuse_report = AbuseReport.new(:reason => params[:report_abuse])
  37 + if !params[:content_type].blank?
  38 + article = params[:content_type].constantize.find(params[:content_id])
  39 + abuse_report.content = article_reported_version(article)
  40 + end
  41 +
  42 + current_person.register_report(abuse_report, profile)
  43 +
  44 + if !params[:content_type].blank?
  45 + abuse_report = AbuseReport.find_by_reporter_id_and_abuse_complaint_id(current_person.id, profile.opened_abuse_complaint.id)
  46 + Delayed::Job.enqueue DownloadReportedImagesJob.new(abuse_report, article)
  47 + end
  48 +
  49 + {
  50 + :success => true,
  51 + :message => _('Your abuse report was registered. The administrators are reviewing your report.'),
  52 + }
  53 + rescue Exception => exception
  54 + #logger.error(exception.to_s)
  55 + render_api_error!(_('Your report couldn\'t be saved due to some problem. Please contact the administrator.'), 400)
  56 + end
  57 +
  58 + end
  59 +
31 60  
32 61 desc "Returns the total followers for the article"
33 62 get ':id/followers' do
... ... @@ -141,7 +170,7 @@ module Noosfero
141 170 article = find_article(community.articles, params[:id])
142 171 present article, :with => Entities::Article, :fields => params[:fields]
143 172 end
144   -
  173 +
145 174 # Example Request:
146 175 # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body
147 176 post do
... ...
plugins/gamification
1   -Subproject commit 350c561d8ca9e138076a160ddfe733c26ed04bf8
  1 +Subproject commit 1f2171520eb4719fefc5a32f26ef2a002cd61f0d
... ...