Skip to content
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

use 'persistent' cookie for 'graphic content' blurring (rather than session cookie) #4189

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion kahuna/public/js/services/graphic-image-blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import angular from "angular";
import 'angular-cookies';

const COOKIE_SHOULD_BLUR_GRAPHIC_IMAGES = 'SHOULD_BLUR_GRAPHIC_IMAGES';
const cookieOptions = {domain: `.${window.location.host}`, path: '/'};
const cookieOptions = {
domain: `.${window.location.host}`,
path: '/',
expires: new Date(Date.now() + 34473600000) //399 days from now (max cookie expiry time)
};

export const graphicImageBlurService = angular.module("kahuna.services.graphicImageBlur", ['ngCookies']).factory(
"graphicImageBlurService",
Expand All @@ -11,6 +15,9 @@ export const graphicImageBlurService = angular.module("kahuna.services.graphicIm
const shouldBlurGraphicImagesCookieValue = $cookies.get(COOKIE_SHOULD_BLUR_GRAPHIC_IMAGES);
const isYetToAcknowledgeBlurGraphicImages = defaultShouldBlurGraphicImages && !shouldBlurGraphicImagesCookieValue; // i.e. cookie not set, one way or the other
const shouldBlurGraphicImages = (shouldBlurGraphicImagesCookieValue || defaultShouldBlurGraphicImages.toString()) === "true";
if (!!shouldBlurGraphicImagesCookieValue){
$cookies.put(COOKIE_SHOULD_BLUR_GRAPHIC_IMAGES, shouldBlurGraphicImages.toString(), cookieOptions); // extend cookie expiry
}
return {
shouldBlurGraphicImages,
isYetToAcknowledgeBlurGraphicImages,
Expand Down