platform:serial8250
     #ˆ¿�þB gí¹ 7ÛóÌƒh¹Ë¾Î      #platform:serial8250
  
   %Ñ239Ð¾Î  ï    %<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>
  5   'ˆl–ßi~” T¾R( 	ÅíÁ
ão)‹Fÿ�þB gí‘ÐÊŸ/óÍƒh¹Ì¿Ï      'scsi:t-0x00
  
   )Ò239Ñ¿Ï  ï    )<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>
  B   +ˆl–ßi~”ÜZÔ%ÝÁ7q )‹Fÿ�þE«6WÃ# ‘Â6 ?Î695Í_‹uÐb&=LtAêÁÑ ·    +{
  "name": "rc",
  "version": "1.2.8",
  "description": "hardwired configuration loader",
  "main": "index.js",
  "browser": "browser.js",
  "scripts": {
    "test": "set -e; node test/test.js; node test/ini.js; node test/nested-env-vars.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/dominictarr/rc.git"
  },
  "license": "(BSD-2-Clause OR MIT OR Apache-2.0)",
  "keywords": [
    "config",
    "rc",
    "unix",
    "defaults"
  ],
  "bin": "./cli.js",
  "author": "Dominic Tarr <dominic.tarr@gmail.com> (dominictarr.com)",
  "dependencies": {
    "deep-extend": "^0.6.0",
    "ini": "~1.3.0",
    "minimist": "^1.2.0",
    "strip-json-comments": "~2.0.1"
  }
}
  D   -ˆl–Ü4ý('ÜZÔâ€vàZ¸ÓJbÑ¿�þHÓ+8Ù‘÷liïçÐƒd,¿Ï_�uÐb&=LyZËcõÃÓ C    -# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

class KnowledgeBase::FeedsController < ApplicationController
  ITEMS_IN_FEED = 10

  prepend_before_action { authorize! }
  prepend_before_action -> { authentication_check_only }, only: %i[root category]

  before_action :ensure_response_format
  before_action :fetch_knowledge_base

  helper_method :build_original_url, :publishing_date, :updating_date

  def root
    scope = if KnowledgeBase.granular_permissions?
              granular_scope
            else
              @knowledge_base.answers
            end

    @answers = scope
      .sorted_by_internally_published(@locale)
      .limit(ITEMS_IN_FEED)

    render :feed
  end

  def category
    @category = @knowledge_base.categories.find(params[:id])

    Pundit.authorize(effective_user, @category, :show_any?)

    scope = if KnowledgeBase.granular_permissions?
              granular_scope [@category]
            else
              @category.self_with_children_answers
            end

    @answers = scope
      .sorted_by_internally_published(@locale)
      .limit(ITEMS_IN_FEED)

    render :feed
  end

  private

  def granular_scope(category_filter = [])
    categories = KnowledgeBase::InternalAssets
      .new(effective_user, categories_filter: category_filter)
      .accessible_categories

    if categories.public_reader.none?
      return @knowledge_base.answers.where(category_id: categories.visible)
    end

    answer_ids = granular_public_answers_ids(categories) + granular_internal_answers_ids(categories)

    @knowledge_base.answers.where(id: answer_ids)
  end

  def granular_public_answers_ids(categories)
    @knowledge_base.answers
      .where(category_id: categories.public_reader)
      .sorted_by_published(@locale)
      .limit(ITEMS_IN_FEED)
      .pluck(:id)
  end

  def granular_internal_answers_ids(categories)
    @knowledge_base.answers
      .where(category_id: categories.internally_visible)
      .sorted_by_internally_published(@locale)
      .limit(ITEMS_IN_FEED)
      .pluck(:id)
  end

  def effective_user
    return current_user if current_user.present?

    Token.check(action: 'KnowledgeBaseFeed', token: params[:token])
  end

  def ensure_response_format
    request.format = :atom
  end

  # Scoped to active knowledge bases, so a feed reader holding a still valid token stops getting
  #   content the moment the knowledge base is switched off â€” the id of a deactivated one is simply
  #   not found. See https://github.com/za