🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

newbamboo-modmonkey_client

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newbamboo-modmonkey_client

bundlerRubygems
Version
0.0.2
Version published
Maintainers
1
Created
Source

There is a ruby gem which handles a lot of stuff for you

General principles

items and profiles which have corresponding things on the server

Models

Item

database fields

  class AddImages < ActiveRecord::Migration
    def self.up
      create_table :test_images do |t|
        t.string :photo_file_name
        t.string :mm_key
        t.string :mm_approved
        t.string :mm_id
        t.string :test_user_id
      end
    end

    def self.down
      drop_table :test_images
    end
  end

Adding moderation to the model

  class Comment < ActiveRecord::Base
    extend ModMonkey::Item::ActMethods
    make_moderatable :content_type=>'text',
                     :profile_info => {
                       :identifier => lambda{|obj| obj.test_user.email},
                       :profile_url => lambda{|obj| SITE_URL+"/test_users/#{obj.test_user.id}"}
                      },
                     :item_url => lambda{|obj| SITE_URL+"/test_comments/#{obj.id}"},
                     :editable_attrs => [:body]

    def mm_content
      { :body => self.body }
    end
  end  

optional attrs and methods

  • content_type
  • mm_content
  • editable_attrs
  • item_url
  • profile_url
  • asset_url

Specifying these values can be done via: lambdas, symbols or variables

callbacks created automatically for the following:

  • create
    • adds item to queue
  • update
    • updates item in queue
  • delete
    • removes item from queue

Though these are automatic, it is usually necessary to think about how failure is handled. Section on this in "Maintenance".

assumptions about moderated content and applying decisions

The default behaviour is to switch mm_approved on or off with a modified find. However this could be overridden to destroy the objects completely, or do some other strategy.

added methods

  • reject
  • approve

usually necessary to apply callbacks to these to cover:

  • cascading
  • banning user
  • emailing notifications

Profile

database fields

  class CreateTestUsers < ActiveRecord::Migration
    def self.up
      create_table :test_users do |t|
        t.string :email
        t.boolean :banned

        t.timestamps
      end
    end

    def self.down
      drop_table :test_users
    end
  end

Adding moderatble functionality

  class User < ActiveRecord::Base
    extend ModMonkey::Profile::ActMethods
    make_moderatable
  end

methods called via the options given:

  • ban
  • unban

usually necessary to apply callbacks to these to cover:

  • cascading
  • banning user
  • emailing notifications

Controllers

SECURITY

implementation - AOP

Items

  class TestImagesController < ApplicationController
    extend ModMonkey::ControllerActMethods
    make_moderatable                    
  end

mm_update

update action applies decision etc

Flags

Method which can be posted to to add a flag to the item in the queue. Can have an optional reason, if UI supports this.

Profile

  
  class TestUsersController < ApplicationController
    extend ModMonkey::ProfileControllerActMethods
    make_moderatable
  end

mm_profile_update checks permission and calls apply_mod_monkey_params

all the callbacks for banning etc

  • doesn't do cascading on the users content on this side, but does on the server ?

Routes

items which are moderated need to have a flags resource which can be posted to - often helpful to have a helper in views

Gotchas

  • login_required

Rake tasks

FAQs

Package last updated on 10 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts