From 3b694c9640f8d0f3e7154785d5569198f673a0a3 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Tue, 18 Apr 2017 23:24:01 -0700 Subject: [PATCH] added DMCA notice to shot page --- server/db-patches/patch-15-16.sql | 2 ++ server/db-patches/patch-16-15.sql | 2 ++ server/src/dbschema.js | 2 +- server/src/pages/shot/model.js | 2 ++ server/src/pages/shot/view.js | 32 +++++++++++++++++++++++++++++++ server/src/servershot.js | 7 +++++-- 6 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 server/db-patches/patch-15-16.sql create mode 100644 server/db-patches/patch-16-15.sql diff --git a/server/db-patches/patch-15-16.sql b/server/db-patches/patch-15-16.sql new file mode 100644 index 0000000000..273674cc76 --- /dev/null +++ b/server/db-patches/patch-15-16.sql @@ -0,0 +1,2 @@ +CREATE TYPE shot_block_type AS ENUM ('none', 'dmca'); +ALTER TABLE data ADD COLUMN block_type shot_block_type DEFAULT 'none' NOT NULL; diff --git a/server/db-patches/patch-16-15.sql b/server/db-patches/patch-16-15.sql new file mode 100644 index 0000000000..654a125640 --- /dev/null +++ b/server/db-patches/patch-16-15.sql @@ -0,0 +1,2 @@ +ALTER TABLE data DROP COLUMN block_type; +DROP TYPE shot_block_type; diff --git a/server/src/dbschema.js b/server/src/dbschema.js index 1fdf89abd9..25b79dd337 100644 --- a/server/src/dbschema.js +++ b/server/src/dbschema.js @@ -4,7 +4,7 @@ const pgpatcher = require("pg-patcher"); const path = require("path"); const mozlog = require("mozlog")("dbschema"); -const MAX_DB_LEVEL = exports.MAX_DB_LEVEL = 15; +const MAX_DB_LEVEL = exports.MAX_DB_LEVEL = 16; exports.forceDbVersion = function(version) { mozlog.info("forcing-db-version", {db: db.constr, version}); diff --git a/server/src/pages/shot/model.js b/server/src/pages/shot/model.js index 03147873f4..f51dfd8a3c 100644 --- a/server/src/pages/shot/model.js +++ b/server/src/pages/shot/model.js @@ -34,6 +34,7 @@ exports.createModel = function(req) { cspNonce: req.cspNonce, hashAnalytics: true, userAgent: req.headers['user-agent'], + blockType: req.shot.blockType, downloadUrl, isMobile }; @@ -61,6 +62,7 @@ exports.createModel = function(req) { defaultExpiration: req.config.defaultExpiration * 1000, hashAnalytics: true, userAgent: req.headers['user-agent'], + blockType: req.shot.blockType, downloadUrl, isMobile }; diff --git a/server/src/pages/shot/view.js b/server/src/pages/shot/view.js index 09e8c46ad0..b427047751 100644 --- a/server/src/pages/shot/view.js +++ b/server/src/pages/shot/view.js @@ -194,12 +194,44 @@ class Body extends React.Component { } render() { + if (this.props.blockType !== 'none') { + return this.renderBlock(); + } if (this.props.expireTime !== null && Date.now() > this.props.expireTime) { return this.renderExpired(); } return this.renderBody(); } + renderBlock() { + let message = null; + let moreInfo = null; + if (this.props.blockType === 'dmca') { + message = "This shot is no longer available due to an intellectual property claim."; + if (this.props.isOwner) { + moreInfo = ( + + Please email dmcanotice@mozilla.com to request further information.
+ Please include the URL of this shot in your email: {this.props.backend}/{this.props.id} +
+ ); + } + } + + return +
+
+
+
+ { message } +
+ { moreInfo } +
+
+
+ ; + } + renderExpired() { let expireTime = this.props.expireTime; if (typeof expireTime != "number") { diff --git a/server/src/servershot.js b/server/src/servershot.js index 17e162fe29..37ddf9c213 100644 --- a/server/src/servershot.js +++ b/server/src/servershot.js @@ -307,6 +307,7 @@ Shot.getRawBytesForClip = function(uid) { JOIN data ON images.shotid = data.id WHERE images.id = $1 AND (data.expire_time IS NULL OR data.expire_time > NOW()) + AND data.block_type = 'none' AND NOT data.deleted`, [uid] ).then((rows) => { if (!rows.length) { @@ -375,6 +376,7 @@ Shot.get = function(backend, id, deviceId) { shot.urlIfDeleted = rawValue.url; shot.expireTime = rawValue.expireTime; shot.deleted = rawValue.deleted; + shot.blockType = rawValue.blockType; return shot; }); }; @@ -403,7 +405,7 @@ Shot.getRawValue = function(id, deviceId) { if (!id) { throw new Error("Empty id: " + id); } - let query = `SELECT value, deviceid, url, title, expire_time, deleted FROM data WHERE id = $1`; + let query = `SELECT value, deviceid, url, title, expire_time, deleted, block_type FROM data WHERE id = $1`; let params = [id]; if (deviceId) { query += ` AND deviceid = $2`; @@ -423,7 +425,8 @@ Shot.getRawValue = function(id, deviceId) { url: row.url, title: row.title, expireTime: row.expire_time, - deleted: row.deleted + deleted: row.deleted, + blockType: row.block_type }; }); };