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
|
# uninstall
|
||||||
# Include both Bridge (legacy) and Link (new) for migration support
|
# 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|
|
package_names.each do |name|
|
||||||
puts "Attempting to uninstall #{name} package..."
|
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",
|
"name": "@link-stack/zammad-addon-proofmode",
|
||||||
"displayName": "MediaVerify",
|
"displayName": "Proofmode",
|
||||||
"version": "3.5.0-beta.1",
|
"version": "3.5.0-beta.1",
|
||||||
"description": "Zammad addon that verifies media attachments for C2PA and ProofMode data using the proofmode-rust library.",
|
"description": "Zammad addon that verifies media attachments for C2PA and ProofMode data using the proofmode-rust library.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# 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).
|
# It is NOT included in the .zpm package (excluded by build script).
|
||||||
# The proofmode gem must be installed at the Docker image level.
|
# The proofmode gem must be installed at the Docker image level.
|
||||||
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CdrMediaVerifyJob < ApplicationJob
|
class ProofmodeVerifyJob < ApplicationJob
|
||||||
BATCH_SIZE = 20
|
BATCH_SIZE = 20
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
return unless Setting.get('media_verify_enabled')
|
return unless Setting.get('proofmode_verify_enabled')
|
||||||
|
|
||||||
articles_to_check.each do |article|
|
articles_to_check.each do |article|
|
||||||
verify_article(article)
|
verify_article(article)
|
||||||
rescue StandardError => e
|
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")
|
Rails.logger.error e.backtrace&.first(5)&.join("\n")
|
||||||
mark_checked(article, error: e.message)
|
mark_checked(article, error: e.message)
|
||||||
end
|
end
|
||||||
|
|
@ -25,7 +25,7 @@ class CdrMediaVerifyJob < ApplicationJob
|
||||||
# Find articles with attachments that haven't been checked yet.
|
# Find articles with attachments that haven't been checked yet.
|
||||||
# We look for articles that:
|
# We look for articles that:
|
||||||
# 1. Have at least one Store (attachment) record
|
# 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
|
# 3. Are from customers (incoming media) - agent articles are unlikely to need verification
|
||||||
article_ids_with_attachments = Store
|
article_ids_with_attachments = Store
|
||||||
.where(store_object_id: store_object_id)
|
.where(store_object_id: store_object_id)
|
||||||
|
|
@ -38,7 +38,7 @@ class CdrMediaVerifyJob < ApplicationJob
|
||||||
Ticket::Article
|
Ticket::Article
|
||||||
.where(id: article_ids_with_attachments)
|
.where(id: article_ids_with_attachments)
|
||||||
.where(sender: Ticket::Article::Sender.find_by(name: 'Customer'))
|
.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)
|
.order(created_at: :desc)
|
||||||
.limit(BATCH_SIZE)
|
.limit(BATCH_SIZE)
|
||||||
end
|
end
|
||||||
|
|
@ -48,21 +48,21 @@ class CdrMediaVerifyJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_article(article)
|
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?
|
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)
|
mark_checked(article)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
body = CdrMediaVerify.format_result(check_output)
|
body = ProofmodeVerify.format_result(check_output)
|
||||||
create_verification_article(article.ticket, article, body)
|
create_verification_article(article.ticket, article, body)
|
||||||
mark_checked(article)
|
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
|
end
|
||||||
|
|
||||||
def create_verification_article(ticket, source_article, body)
|
def create_verification_article(ticket, source_article, body)
|
||||||
|
|
@ -75,8 +75,8 @@ class CdrMediaVerifyJob < ApplicationJob
|
||||||
sender: Ticket::Article::Sender.find_by(name: 'System'),
|
sender: Ticket::Article::Sender.find_by(name: 'System'),
|
||||||
type: Ticket::Article::Type.find_by(name: 'note'),
|
type: Ticket::Article::Type.find_by(name: 'note'),
|
||||||
preferences: {
|
preferences: {
|
||||||
media_verify_report: true,
|
proofmode_report: true,
|
||||||
media_verify_source_article_id: source_article.id,
|
proofmode_source_article_id: source_article.id,
|
||||||
},
|
},
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
|
|
@ -84,9 +84,9 @@ class CdrMediaVerifyJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_checked(article, error: nil)
|
def mark_checked(article, error: nil)
|
||||||
article.preferences['media_verify_checked'] = 'true'
|
article.preferences['proofmode_checked'] = 'true'
|
||||||
article.preferences['media_verify_checked_at'] = Time.current.iso8601
|
article.preferences['proofmode_checked_at'] = Time.current.iso8601
|
||||||
article.preferences['media_verify_error'] = error if error
|
article.preferences['proofmode_error'] = error if error
|
||||||
article.save!
|
article.save!
|
||||||
end
|
end
|
||||||
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
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class MediaVerifyAddMediaVerify < ActiveRecord::Migration[5.2]
|
class ProofmodeAddProofmodeVerify < ActiveRecord::Migration[5.2]
|
||||||
def self.up
|
def self.up
|
||||||
# Setting to enable/disable media verification
|
# Setting to enable/disable media verification
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'Media Verification',
|
title: 'Proofmode Verification',
|
||||||
name: 'media_verify_enabled',
|
name: 'proofmode_verify_enabled',
|
||||||
area: 'Integration::MediaVerify',
|
area: 'Integration::Proofmode',
|
||||||
description: 'Enable automatic verification of media attachments for C2PA and ProofMode data.',
|
description: 'Enable automatic verification of media attachments for C2PA and ProofMode data.',
|
||||||
options: {
|
options: {
|
||||||
form: [
|
form: [
|
||||||
{
|
{
|
||||||
display: '',
|
display: '',
|
||||||
null: true,
|
null: true,
|
||||||
name: 'media_verify_enabled',
|
name: 'proofmode_verify_enabled',
|
||||||
tag: 'boolean',
|
tag: 'boolean',
|
||||||
options: {
|
options: {
|
||||||
true => 'yes',
|
true => 'yes',
|
||||||
|
|
@ -33,7 +33,7 @@ class MediaVerifyAddMediaVerify < ActiveRecord::Migration[5.2]
|
||||||
# Scheduler to run media verification checks
|
# Scheduler to run media verification checks
|
||||||
Scheduler.create_if_not_exists(
|
Scheduler.create_if_not_exists(
|
||||||
name: 'Verify media attachments for C2PA and ProofMode data',
|
name: 'Verify media attachments for C2PA and ProofMode data',
|
||||||
method: 'CdrMediaVerifyJob.perform_now',
|
method: 'ProofmodeVerifyJob.perform_now',
|
||||||
period: 5.minutes,
|
period: 5.minutes,
|
||||||
prio: 3,
|
prio: 3,
|
||||||
active: true,
|
active: true,
|
||||||
|
|
@ -44,6 +44,6 @@ class MediaVerifyAddMediaVerify < ActiveRecord::Migration[5.2]
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
Scheduler.find_by(name: 'Verify media attachments for C2PA and ProofMode data')&.destroy
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -4,7 +4,7 @@ require 'proofmode'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
|
||||||
class CdrMediaVerify
|
class ProofmodeVerify
|
||||||
VERIFIABLE_CONTENT_TYPES = %w[
|
VERIFIABLE_CONTENT_TYPES = %w[
|
||||||
image/jpeg
|
image/jpeg
|
||||||
image/png
|
image/png
|
||||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
|
|
@ -235,7 +235,7 @@ importers:
|
||||||
specifier: ^5
|
specifier: ^5
|
||||||
version: 5.9.3
|
version: 5.9.3
|
||||||
|
|
||||||
packages/zammad-addon-media-verify:
|
packages/zammad-addon-proofmode:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@link-stack/zammad-addon-common':
|
'@link-stack/zammad-addon-common':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue