Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented emailing of abuse reporting

  • Loading branch information...
commit 99527cb86b1d09c90ea463d6dfc3eaf58d2fbbaf 1 parent b1faabb
@binarytales binarytales authored aron committed
View
3  config.default.json
@@ -42,7 +42,8 @@
"logger": "default"
},
"notify": {
- "errors": []
+ "errors": [],
+ "report": []
},
"blacklist": {
"html": ["processform.cgi", "habbo.com"],
View
23 lib/handlers/bin.js
@@ -15,6 +15,7 @@ module.exports = Observable.extend({
this.models = sandbox.models;
this.helpers = sandbox.helpers;
+ this.mailer = sandbox.mailer;
// For now we bind all methods to the class scope. In reality only those
// used as route callbacks need to be bound.
@@ -747,5 +748,27 @@ module.exports = Observable.extend({
helpers.render('history', {bins: data}, fn);
}
});
+ },
+ report: function (req, res, next) {
+ var bin = req.bin,
+ _this = this;
+
+ this.models.bin.report(bin, function (err) {
+ if (err) {
+ return next(err);
+ }
+
+ var to = _this.helpers.set('notify report');
+
+ if (true || _this.helpers.production && to && to.length) {
+ _this.mailer.reportBin(to, _this.helpers.url(req.url, true));
+ }
+
+ res.render('report', {
+ root: _this.helpers.url(),
+ dave: _this.helpers.url('/images/logo.png', false, true)
+ });
+
+ });
}
});
View
16 lib/handlers/mail.js
@@ -41,6 +41,22 @@ module.exports = Observable.extend({
}, fn);
});
},
+ reportBin: function (to, url, fn) {
+ var _this = this;
+
+ this.render('report_email.txt', {url:url}, function (err, body) {
+ if (err) {
+ return fn(err);
+ }
+
+ _this.sendMail({
+ from: "Dave <dave-the-robot@jsbin.com>",
+ to: to,
+ subject: 'JS Bin Abuse Report',
+ text: body
+ }, fn);
+ });
+ },
sendMail: function (options, fn) {
var error = new errors.MailerError('Mail Transport is not configured');
View
2  lib/routes.js
@@ -69,6 +69,8 @@ module.exports = function (app) {
app.get('/:bin/:rev?/watch', tag('live'), binHandler.getBin);
app.get('/:bin/:rev?/embed', tag('embed'), binHandler.getBin);
+ app.get('/:bin/:rev?/report', binHandler.report);
+
// Save
app.post('/save', binHandler.createBin);
View
210 views/report.html
@@ -0,0 +1,210 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>Uh-oh Something Went Wrong</title>
+ <style>
+ body {
+ padding: 0;
+ margin: 0;
+ font-family: 'Doppio One', sans-serif;
+ background: #3FA8C6;
+ background: -moz-linear-gradient(top, #3fa8c6 0%, #3fa8c6 0%, #399ab2 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3fa8c6), color-stop(0%,#3fa8c6), color-stop(100%,#399ab2));
+ background: -webkit-linear-gradient(top, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
+ background: -o-linear-gradient(top, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
+ background: -ms-linear-gradient(top, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
+ background: linear-gradient(to bottom, #3fa8c6 0%,#3fa8c6 0%,#399ab2 100%);
+ background-color: #399AB2;
+ background-repeat: repeat-x;
+ color: #fff;
+ text-shadow: 0 1px 0 rgba(0,0,0,.3);
+ line-height: 1.5;
+ -webkit-font-smoothing: antialiased;
+ }
+
+ .wrapper {
+ width: 50%;
+ margin: 0 auto;
+ }
+
+ h1, h2, h3, h4, h5, h6 {
+ letter-spacing: -0.03em;
+ font-size: 2em;
+ }
+
+ a {
+ color: white;
+ text-decoration: none;
+ border-bottom: 1px solid #fff;
+ border-bottom: 1px solid rgba(255,255,255,0.7);
+ padding-bottom: 0.15em;
+ position: relative;
+ }
+
+ a:after {
+ content: '';
+ position: absolute;
+ height: 1px;
+ left: 0;
+ right: 0;
+ bottom: -2px;
+ background: rgba(0,0,0,.1);
+ }
+
+ a:hover {
+ color: #C0E3EC;
+ }
+
+ h1 {
+ text-align: left;
+ margin: 0.667em 0 0;
+ padding-left: 0.5em;
+ }
+
+ h2 {
+ font-size: 1.5em;
+ }
+
+ small {
+ margin-top: 1em;
+ display: block;
+ font-style: italic;
+ font-size: 0.667em;
+ }
+
+ p em {
+ font-style: none;
+ }
+
+ #welcome {
+ position: relative;
+ overflow: hidden;
+ padding-bottom: 1em;
+ padding-left: 20px;
+ }
+
+ #welcome > div {
+ padding-top: 1px;
+ }
+
+ #dave {
+ float: left;
+ margin-top: 3em
+ }
+
+ #welcome > h2 {
+ margin-top: 0.5em;
+ padding-left: 0.5em;
+ margin-bottom: 0;
+ }
+
+ .bubble p {
+ line-height: 22px;
+ }
+
+ .bubble {
+ background: rgba(255, 255, 255, 0.1);
+ border-color: rgba(255, 255, 255, 0.1);
+
+ padding: 0.667em 1em;
+ position: relative;
+ }
+
+ .bubble:after {
+ content: "";
+ position: absolute;
+ width: 0;
+ height: 0;
+ border-top: 20px solid transparent;
+ border-bottom: 20px solid transparent;
+ border-right: 20px solid white;
+ border-right-color: inherit;
+ top: 50px;
+ left: -20px;
+ }
+
+ img {
+ z-index: 1;
+ -webkit-transition: -webkit-transform 2s ease-in-out;
+ -moz-transition: -moz-transform 2s ease-in-out;
+ -o-transition: -o-transform 2s ease-in-out;
+ -ms-transition: -ms-transform 2s ease-in-out;
+ transition: transform 2s ease-in-out;
+ position: relative;
+ }
+
+ img:active {
+ -webkit-transform: rotate(1440deg) scale(1.2);
+ -moz-transform: rotate(1440deg) scale(1.2);
+ -o-transform: rotate(1440deg) scale(1.2);
+ -ms-transform: rotate(1440deg) scale(1.2);
+ transform: rotate(1440deg) scale(1.2);
+ }
+
+ @media screen and (max-width: 1200px) {
+ .wrapper {
+ width: 80%;
+ }
+ }
+
+ @media screen and (max-width: 768px) {
+ .wrapper {
+ width: auto;
+ margin: 0;
+ }
+ #welcome {
+ margin-right: 2.5%;
+ }
+ }
+
+ @media screen and (max-width: 500px) {
+ .wrapper {
+ text-align: center;
+ }
+
+ #dave {
+ float: none;
+ }
+
+ #welcome {
+ padding: 0 1.5em;
+ margin: 0;
+ }
+
+ h1 {
+ text-align: center;
+ margin-bottom: 0;
+ padding-left: 0;
+ font-size: 1.8em;
+ }
+
+ #welcome > h2 {
+ margin-bottom: 0.667em;
+ }
+ .bubble {
+ text-align: center;
+ }
+ .bubble:after {
+ display: none;
+ }
+ }
+ </style>
+ </head>
+ <body>
+ <div class="wrapper">
+ <img id="dave" src="{{dave}}" alt="Dave, the JS Bin bot">
+ <div id="welcome">
+ <h1>Report Abuse</h1>
+ <div class="bubble">
+ <p>Thanks for flagging that for me. I'll investigate things a bit
+ more and take any appropiate action</p>
+ <p>How about heading back to the <a href="{{root}}">homepage</a>
+ instead? It's nice there and there are lots of things to click on.</p>
+ <p>If you think there is supposed to be something here that isn't
+ let us know via the <a href="http://github.com/remy/jsbin/issues">Issues page</a>.</p>
+ </div>
+ </div>
+ </div>
+ </body>
+</html>
View
7 views/report_email.txt
@@ -0,0 +1,7 @@
+Hey,
+
+Somebody went and reported a bin as being a bit dodgy. It was this one: {{url}}
+
+Cheers,
+
+Dave
Please sign in to comment.
Something went wrong with that request. Please try again.