Commit c279721d48ee70de18a9850a295533202c057d8b
1 parent
268ebd86
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
API: Adding report abuse support for articles
Showing
2 changed files
with
31 additions
and
2 deletions
Show diff stats
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