-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add moderation zones where anonymous notes are not allowed #6713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Would use postgis:15-3.5, but it doesn't work with Apple Silicon | ||
| # (https://github.com/postgis/docker-postgis/issues/216). | ||
| # Therefore we use postgres:15 and apt-install Postgis ourselves. | ||
| FROM postgres:15 | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install --no-install-recommends -y \ | ||
| postgresql-15-postgis-3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # == Schema Information | ||
| # | ||
| # Table name: moderation_zones | ||
| # | ||
| # id :bigint not null, primary key | ||
| # name :string not null | ||
| # reason :string not null | ||
| # reason_format :enum default("markdown") | ||
| # zone :st_polygon not null, polygon, 4326 | ||
| # ends_at :datetime | ||
| # creator_id :bigint not null | ||
| # revoker_id :bigint | ||
| # created_at :datetime not null | ||
| # updated_at :datetime not null | ||
| # | ||
| # Indexes | ||
| # | ||
| # index_moderation_zones_on_creator_id (creator_id) | ||
| # index_moderation_zones_on_revoker_id (revoker_id) | ||
| # | ||
| # Foreign Keys | ||
| # | ||
| # fk_rails_... (creator_id => users.id) | ||
| # fk_rails_... (revoker_id => users.id) | ||
| # | ||
| class ModerationZone < ApplicationRecord | ||
| belongs_to :creator, :class_name => "User" | ||
| belongs_to :revoker, :class_name => "User", :optional => true | ||
|
|
||
| validates :name, :presence => true | ||
| validates :reason, :presence => true | ||
| validates :zone, :presence => true | ||
|
|
||
| def self.falls_within_any?(lon:, lat:) | ||
| factory = RGeo::Cartesian.simple_factory(:srid => 4326) | ||
| point = factory.point(lon, lat) | ||
|
|
||
| where( | ||
| arel_table[:zone].st_contains(point) | ||
| ).exists? | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class EnablePostgis < ActiveRecord::Migration[8.1] | ||
| def change | ||
| enable_extension "postgis" | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class CreateModerationZones < ActiveRecord::Migration[8.1] | ||
| def change | ||
| create_table :moderation_zones do |t| | ||
| t.string :name, :null => false | ||
| t.string :reason, :null => false | ||
| t.column :reason_format, :format_enum, :default => "markdown" | ||
| t.st_polygon :zone, :srid => 4326, :null => false | ||
| t.datetime :ends_at | ||
|
|
||
| t.references :creator, :null => false, :foreign_key => { :to_table => :users } | ||
| t.references :revoker, :foreign_key => { :to_table => :users } | ||
|
|
||
| t.timestamps | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
| # Would use postgis:14-3.5, but it doesn't work with Apple Silicon | ||
| # (https://github.com/postgis/docker-postgis/issues/216). | ||
| # Therefore we use postgres:14 and apt-install Postgis ourselves. | ||
| FROM postgres:14 | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install --no-install-recommends -y \ | ||
| postgresql-14-postgis-3 | ||
|
|
||
| # Add db init script to install OSM-specific Postgres user. | ||
| ADD docker/postgres/openstreetmap-postgres-init.sh /docker-entrypoint-initdb.d/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.