From 984eab65017d29a47259092ab7e5592624b2c570 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Fri, 26 Feb 2016 22:09:57 -0800 Subject: [PATCH] Added doNotTrack option to the API. --- Teknik/Areas/API/Controllers/APIv1Controller.cs | 15 +++++++++------ Teknik/Areas/Help/Views/Help/API/v1/Paste.cshtml | 14 ++++++++++++++ .../Areas/Help/Views/Help/API/v1/Shorten.cshtml | 14 ++++++++++++++ Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml | 14 ++++++++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Teknik/Areas/API/Controllers/APIv1Controller.cs b/Teknik/Areas/API/Controllers/APIv1Controller.cs index 0ae75ec..7398e98 100644 --- a/Teknik/Areas/API/Controllers/APIv1Controller.cs +++ b/Teknik/Areas/API/Controllers/APIv1Controller.cs @@ -27,11 +27,12 @@ namespace Teknik.Areas.API.Controllers [HttpPost] [AllowAnonymous] - public ActionResult Upload(HttpPostedFileWrapper file, string contentType = null, bool encrypt = false, bool saveKey = false, string key = null, int keySize = 0, string iv = null, int blockSize = 0, bool genDeletionKey = false) + public ActionResult Upload(HttpPostedFileWrapper file, string contentType = null, bool encrypt = false, bool saveKey = false, string key = null, int keySize = 0, string iv = null, int blockSize = 0, bool genDeletionKey = false, bool doNotTrack = false) { try { - Tracking.TrackPageView(Request, "Upload"); + if (!doNotTrack) + Tracking.TrackPageView(Request, "Upload"); if (file != null) { if (file.ContentLength <= Config.UploadConfig.MaxUploadSize) @@ -127,11 +128,12 @@ namespace Teknik.Areas.API.Controllers [HttpPost] [AllowAnonymous] - public ActionResult Paste(string code, string title = "", string syntax = "auto", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false) + public ActionResult Paste(string code, string title = "", string syntax = "auto", string expireUnit = "never", int expireLength = 1, string password = "", bool hide = false, bool doNotTrack = false) { try { - Tracking.TrackPageView(Request, "Paste"); + if (!doNotTrack) + Tracking.TrackPageView(Request, "Paste"); Paste.Models.Paste paste = PasteHelper.CreatePaste(code, title, syntax, expireUnit, expireLength, password, hide); db.Pastes.Add(paste); @@ -156,11 +158,12 @@ namespace Teknik.Areas.API.Controllers } } - public ActionResult Shorten(string url) + public ActionResult Shorten(string url, bool doNotTrack = false) { try { - Tracking.TrackPageView(Request, "Shorten"); + if (!doNotTrack) + Tracking.TrackPageView(Request, "Shorten"); if (url.IsValidUrl()) { ShortenedUrl newUrl = Shortener.Shortener.ShortenUrl(url, Config.ShortenerConfig.UrlLength); diff --git a/Teknik/Areas/Help/Views/Help/API/v1/Paste.cshtml b/Teknik/Areas/Help/Views/Help/API/v1/Paste.cshtml index b9e1a9c..13315a8 100644 --- a/Teknik/Areas/Help/Views/Help/API/v1/Paste.cshtml +++ b/Teknik/Areas/Help/Views/Help/API/v1/Paste.cshtml @@ -129,6 +129,20 @@ If the paste should be visible in the most recent pastes list. + + + doNotTrack + + + bool + + + false + + + If you do not want the api request to be tracked as defined in the privacy policy. + +

Response

diff --git a/Teknik/Areas/Help/Views/Help/API/v1/Shorten.cshtml b/Teknik/Areas/Help/Views/Help/API/v1/Shorten.cshtml index f0c2cc1..8e2ca74 100644 --- a/Teknik/Areas/Help/Views/Help/API/v1/Shorten.cshtml +++ b/Teknik/Areas/Help/Views/Help/API/v1/Shorten.cshtml @@ -35,6 +35,20 @@ The url you want to shorten. This url must be an absolute url. + + + doNotTrack + + + bool + + + false + + + If you do not want the api request to be tracked as defined in the privacy policy. + +

Response

diff --git a/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml b/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml index 18e0993..8c7523a 100644 --- a/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml +++ b/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml @@ -147,6 +147,20 @@ Generates a deletion key. + + + doNotTrack + + + bool + + + false + + + If you do not want the api request to be tracked as defined in the privacy policy. + +

Response