diff --git a/assets/ui/components/ArticleBodyHtml.jsx b/assets/ui/components/ArticleBodyHtml.jsx
index d68191a8..d1b7b365 100644
--- a/assets/ui/components/ArticleBodyHtml.jsx
+++ b/assets/ui/components/ArticleBodyHtml.jsx
@@ -5,7 +5,6 @@ import {formatHTML} from 'utils';
import {connect} from 'react-redux';
import {selectCopy} from '../../wire/actions';
import DOMPurify from 'dompurify';
-// import fallbackDefault from 'images/poster_default.jpg'
const fallbackDefault = '/static/poster_default.jpg';
class ArticleBodyHtml extends React.PureComponent {
@@ -13,7 +12,6 @@ class ArticleBodyHtml extends React.PureComponent {
super(props);
this.state = {
sanitizedHtml: '',
- memoryUsage: null
};
this.copyClicked = this.copyClicked.bind(this);
this.clickClicked = this.clickClicked.bind(this);
@@ -21,7 +19,6 @@ class ArticleBodyHtml extends React.PureComponent {
this.getBodyHTML = memoize(this._getBodyHTML.bind(this));
this.bodyRef = React.createRef();
this.players = new Map();
- this.memoryInterval = null;
}
componentDidMount() {
@@ -53,9 +50,9 @@ class ArticleBodyHtml extends React.PureComponent {
this.players.forEach(player => player.destroy());
this.players.clear();
- if (this.memoryInterval) {
- clearInterval(this.memoryInterval);
- }
+ // if (this.memoryInterval) {
+ // clearInterval(this.memoryInterval);
+ // }
}
startMemoryUsageTracking() {
@@ -232,8 +229,6 @@ class ArticleBodyHtml extends React.PureComponent {
return;
}
const loadHandler = () => {
- // eslint-disable-next-line no-console
- console.log('Initial dimensions:', player.media.videoWidth, player.media.videoHeight);
const checkVideoContent = () => {
if (player.media.videoWidth > 0 && player.media.videoHeight > 0) {
const canvas = document.createElement('canvas');
@@ -245,12 +240,10 @@ class ArticleBodyHtml extends React.PureComponent {
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
// loop for none blank pixel
- let stepSize = 4; // Adjust the step size as needed
+ let stepSize = 8; // Adjust the step size
for (let i = 0; i < data.length; i += stepSize * 4) {
if (data[i] > 0 || data[i + 1] > 0 || data[i + 2] > 0) {
-
- // eslint-disable-next-line no-console
- console.log('Pixel content detected, poster not needed');
+ console.warn('Pixel content detected, poster not needed');
return true;
}
}
@@ -261,15 +254,14 @@ class ArticleBodyHtml extends React.PureComponent {
const attemptContentCheck = () => {
if (checkVideoContent()) {
player.poster = null;
- // eslint-disable-next-line no-console
- console.log('Pixel content detected, poster removed');
+ console.warn('Pixel content detected, poster removed');
return true;
}
return false;
};
let attemptCount = 0;
- const maxAttempts = 2;
+ const maxAttempts = 1;
const checkInterval = setInterval(() => {
if (attemptContentCheck() || attemptCount >= maxAttempts) {
clearInterval(checkInterval);
@@ -285,7 +277,7 @@ class ArticleBodyHtml extends React.PureComponent {
};
player.on('error', (error) => {
- console.error('Error details:', {
+ console.error('Error details and location:', {
message: error.message,
code: error.code,
type: error.type,
diff --git a/newsroom/companies/views.py b/newsroom/companies/views.py
index ea53d734..2144b7b7 100644
--- a/newsroom/companies/views.py
+++ b/newsroom/companies/views.py
@@ -175,7 +175,7 @@ def update_company(data, _id):
@account_manager_only
def save_company_permissions(_id):
csrf_token = request.headers.get('X-CSRF-Token')
- expected_csrf_token = session.get('csrf_token')
+ expected_csrf_token = session.pop('csrf_token')
orig = get_entity_or_404(_id, 'companies')
data = get_json_or_400()
if not csrf_token or csrf_token != expected_csrf_token:
diff --git a/newsroom/wire/block_media/download_items.py b/newsroom/wire/block_media/download_items.py
index 367ae9c9..765476d6 100644
--- a/newsroom/wire/block_media/download_items.py
+++ b/newsroom/wire/block_media/download_items.py
@@ -9,7 +9,24 @@
def filter_items_download(func):
+ """
+ A decorator that filters downloaded items based on a given filter function.
+
+ :param func: The function to be decorated. It should take _ids and item_type as parameters
+ and return a list of items.
+ :return: A wrapper function that adds filtering capability to the decorated function.
+ """
def wrapper(_ids, item_type, filter_func=None):
+ """
+ Wrapper function that calls the decorated function and applies optional filtering.
+
+ :param _ids: List of IDs to download items for.
+ :param item_type: Type of items to download .
+ :param filter_func: Optional function to filter the downloaded items.
+ default is None, no filtering is applied.
+ :return: A list of downloaded items, potentially filtered if a filter_func is provided
+ and the item_type is not 'agenda'.
+ """
items = func(_ids, item_type)
if filter_func and items and (item_type != 'agenda'):
items = filter_func(items)
diff --git a/newsroom/wire/block_media/permission_media.py b/newsroom/wire/block_media/permission_media.py
deleted file mode 100644
index 996fe3fc..00000000
--- a/newsroom/wire/block_media/permission_media.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from newsroom.auth import get_user
-from newsroom.companies import get_user_company
-from newsroom.products.products import get_products_by_company
-from flask import request
-
-
-class PermissionMedia:
- @staticmethod
- def permission_editor_in_item(item):
- user = get_user(required=True)
- company = get_user_company(user)
-
- if company is None:
- return []
-
- permitted_products = [p.get('sd_product_id') for p in
- get_products_by_company(company.get('_id'), None, request.args.get('type', 'wire'))
- if p.get('sd_product_id')]
-
- disable_download = []
- for key, embed_item in item.get("associations", {}).items():
- if key.startswith("editor_") and embed_item and embed_item.get('type') in ['audio', 'video', 'picture']:
- embed_products = [p.get('code') for p in
- ((item.get('associations') or {}).get(key) or {}).get('products', [])]
-
- if not set(embed_products) & set(permitted_products):
- disable_download.append(key)
-
- return disable_download
diff --git a/newsroom/wire/search.py b/newsroom/wire/search.py
index 68e105d3..013bf2c4 100644
--- a/newsroom/wire/search.py
+++ b/newsroom/wire/search.py
@@ -1,3 +1,4 @@
+import logging
from datetime import datetime, timedelta
from copy import deepcopy
from eve.utils import ParsedRequest, config
@@ -18,9 +19,8 @@
from newsroom.companies import get_user_company
from newsroom.products.products import get_products_by_company
from newsroom.wire.block_media.filter_media import filter_media
-from superdesk.logging import logger
-# logger = logging.getLogger(__name__)
+logger = logging.getLogger(__name__)
def get_bookmarks_count(user_id, product_type):