Rename media-verify addon to Proofmode, remove CDR prefixes
Renames the addon from zammad-addon-media-verify to zammad-addon-proofmode and removes all cdr_ prefixes from file names and class names per project naming convention. - Package: @link-stack/zammad-addon-proofmode (displayName: Proofmode) - Classes: ProofmodeVerify, ProofmodeVerifyJob - Files: proofmode_verify.rb, proofmode_verify_job.rb - Settings: proofmode_verify_enabled - Migration dir: db/addon/proofmode/ https://claude.ai/code/session_01GJYbRCFFJCJDAEcEVbD36N
This commit is contained in:
parent
33375c9221
commit
3f13c00f12
13 changed files with 35 additions and 35 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# uninstall
|
||||
# Include both Bridge (legacy) and Link (new) for migration support
|
||||
package_names = %w[Hardening Bridge Link MediaVerify]
|
||||
package_names = %w[Hardening Bridge Link Proofmode]
|
||||
|
||||
package_names.each do |name|
|
||||
puts "Attempting to uninstall #{name} package..."
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
require 'cdr_media_verify'
|
||||
|
||||
Rails.logger.info 'CDR MediaVerify addon loaded'
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-media-verify",
|
||||
"displayName": "MediaVerify",
|
||||
"name": "@link-stack/zammad-addon-proofmode",
|
||||
"displayName": "Proofmode",
|
||||
"version": "3.5.0-beta.1",
|
||||
"description": "Zammad addon that verifies media attachments for C2PA and ProofMode data using the proofmode-rust library.",
|
||||
"scripts": {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This Gemfile documents Ruby dependencies for the media-verify addon.
|
||||
# This Gemfile documents Ruby dependencies for the proofmode addon.
|
||||
# It is NOT included in the .zpm package (excluded by build script).
|
||||
# The proofmode gem must be installed at the Docker image level.
|
||||
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CdrMediaVerifyJob < ApplicationJob
|
||||
class ProofmodeVerifyJob < ApplicationJob
|
||||
BATCH_SIZE = 20
|
||||
|
||||
def perform
|
||||
return unless Setting.get('media_verify_enabled')
|
||||
return unless Setting.get('proofmode_verify_enabled')
|
||||
|
||||
articles_to_check.each do |article|
|
||||
verify_article(article)
|
||||
rescue StandardError => e
|
||||
Rails.logger.error "MediaVerify: Failed to check article #{article.id}: #{e.message}"
|
||||
Rails.logger.error "ProofmodeVerify: Failed to check article #{article.id}: #{e.message}"
|
||||
Rails.logger.error e.backtrace&.first(5)&.join("\n")
|
||||
mark_checked(article, error: e.message)
|
||||
end
|
||||
|
|
@ -25,7 +25,7 @@ class CdrMediaVerifyJob < ApplicationJob
|
|||
# Find articles with attachments that haven't been checked yet.
|
||||
# We look for articles that:
|
||||
# 1. Have at least one Store (attachment) record
|
||||
# 2. Haven't been marked as media_verify_checked in preferences
|
||||
# 2. Haven't been marked as proofmode_checked in preferences
|
||||
# 3. Are from customers (incoming media) - agent articles are unlikely to need verification
|
||||
article_ids_with_attachments = Store
|
||||
.where(store_object_id: store_object_id)
|
||||
|
|
@ -38,7 +38,7 @@ class CdrMediaVerifyJob < ApplicationJob
|
|||
Ticket::Article
|
||||
.where(id: article_ids_with_attachments)
|
||||
.where(sender: Ticket::Article::Sender.find_by(name: 'Customer'))
|
||||
.where.not("preferences->>'media_verify_checked' = ?", 'true')
|
||||
.where.not("preferences->>'proofmode_checked' = ?", 'true')
|
||||
.order(created_at: :desc)
|
||||
.limit(BATCH_SIZE)
|
||||
end
|
||||
|
|
@ -48,21 +48,21 @@ class CdrMediaVerifyJob < ApplicationJob
|
|||
end
|
||||
|
||||
def verify_article(article)
|
||||
Rails.logger.info "MediaVerify: Checking article #{article.id} on ticket #{article.ticket_id}"
|
||||
Rails.logger.info "ProofmodeVerify: Checking article #{article.id} on ticket #{article.ticket_id}"
|
||||
|
||||
check_output = CdrMediaVerify.check_article(article)
|
||||
check_output = ProofmodeVerify.check_article(article)
|
||||
|
||||
if check_output.nil?
|
||||
Rails.logger.debug { "MediaVerify: No verifiable attachments in article #{article.id}" }
|
||||
Rails.logger.debug { "ProofmodeVerify: No verifiable attachments in article #{article.id}" }
|
||||
mark_checked(article)
|
||||
return
|
||||
end
|
||||
|
||||
body = CdrMediaVerify.format_result(check_output)
|
||||
body = ProofmodeVerify.format_result(check_output)
|
||||
create_verification_article(article.ticket, article, body)
|
||||
mark_checked(article)
|
||||
|
||||
Rails.logger.info "MediaVerify: Posted verification report for article #{article.id}"
|
||||
Rails.logger.info "ProofmodeVerify: Posted verification report for article #{article.id}"
|
||||
end
|
||||
|
||||
def create_verification_article(ticket, source_article, body)
|
||||
|
|
@ -75,8 +75,8 @@ class CdrMediaVerifyJob < ApplicationJob
|
|||
sender: Ticket::Article::Sender.find_by(name: 'System'),
|
||||
type: Ticket::Article::Type.find_by(name: 'note'),
|
||||
preferences: {
|
||||
media_verify_report: true,
|
||||
media_verify_source_article_id: source_article.id,
|
||||
proofmode_report: true,
|
||||
proofmode_source_article_id: source_article.id,
|
||||
},
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
|
|
@ -84,9 +84,9 @@ class CdrMediaVerifyJob < ApplicationJob
|
|||
end
|
||||
|
||||
def mark_checked(article, error: nil)
|
||||
article.preferences['media_verify_checked'] = 'true'
|
||||
article.preferences['media_verify_checked_at'] = Time.current.iso8601
|
||||
article.preferences['media_verify_error'] = error if error
|
||||
article.preferences['proofmode_checked'] = 'true'
|
||||
article.preferences['proofmode_checked_at'] = Time.current.iso8601
|
||||
article.preferences['proofmode_error'] = error if error
|
||||
article.save!
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
require 'proofmode_verify'
|
||||
|
||||
Rails.logger.info 'Proofmode verification addon loaded'
|
||||
end
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MediaVerifyAddMediaVerify < ActiveRecord::Migration[5.2]
|
||||
class ProofmodeAddProofmodeVerify < ActiveRecord::Migration[5.2]
|
||||
def self.up
|
||||
# Setting to enable/disable media verification
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Media Verification',
|
||||
name: 'media_verify_enabled',
|
||||
area: 'Integration::MediaVerify',
|
||||
title: 'Proofmode Verification',
|
||||
name: 'proofmode_verify_enabled',
|
||||
area: 'Integration::Proofmode',
|
||||
description: 'Enable automatic verification of media attachments for C2PA and ProofMode data.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'media_verify_enabled',
|
||||
name: 'proofmode_verify_enabled',
|
||||
tag: 'boolean',
|
||||
options: {
|
||||
true => 'yes',
|
||||
|
|
@ -33,7 +33,7 @@ class MediaVerifyAddMediaVerify < ActiveRecord::Migration[5.2]
|
|||
# Scheduler to run media verification checks
|
||||
Scheduler.create_if_not_exists(
|
||||
name: 'Verify media attachments for C2PA and ProofMode data',
|
||||
method: 'CdrMediaVerifyJob.perform_now',
|
||||
method: 'ProofmodeVerifyJob.perform_now',
|
||||
period: 5.minutes,
|
||||
prio: 3,
|
||||
active: true,
|
||||
|
|
@ -44,6 +44,6 @@ class MediaVerifyAddMediaVerify < ActiveRecord::Migration[5.2]
|
|||
|
||||
def self.down
|
||||
Scheduler.find_by(name: 'Verify media attachments for C2PA and ProofMode data')&.destroy
|
||||
Setting.find_by(name: 'media_verify_enabled')&.destroy
|
||||
Setting.find_by(name: 'proofmode_verify_enabled')&.destroy
|
||||
end
|
||||
end
|
||||
|
|
@ -4,7 +4,7 @@ require 'proofmode'
|
|||
require 'json'
|
||||
require 'tempfile'
|
||||
|
||||
class CdrMediaVerify
|
||||
class ProofmodeVerify
|
||||
VERIFIABLE_CONTENT_TYPES = %w[
|
||||
image/jpeg
|
||||
image/png
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
|
|
@ -235,7 +235,7 @@ importers:
|
|||
specifier: ^5
|
||||
version: 5.9.3
|
||||
|
||||
packages/zammad-addon-media-verify:
|
||||
packages/zammad-addon-proofmode:
|
||||
dependencies:
|
||||
'@link-stack/zammad-addon-common':
|
||||
specifier: workspace:*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue