Use _uid instead of _id to please Rails
This commit is contained in:
parent
87bb05fdd5
commit
ac42d7df78
22 changed files with 151 additions and 50 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-common",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"main": "build/main/index.js",
|
||||
"type": "module",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/bridge-ui",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/eslint-config",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "amigo's eslint config",
|
||||
"main": "index.js",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/jest-config",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/logger",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "Shared logging utility for Link Stack monorepo",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/signal-api",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"type": "module",
|
||||
"main": "build/index.js",
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/typescript-config",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "Shared TypeScript config",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": "Abel Luck <abel@guardianproject.info>",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/ui",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-bridge",
|
||||
"displayName": "Bridge",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "An addon that adds CDR Bridge channels to Zammad.",
|
||||
"scripts": {
|
||||
"build": "node '../zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
|
||||
# Lookup customer with fallback chain:
|
||||
# 1. Phone number in phone/mobile fields (preferred)
|
||||
# 2. Signal user ID in signal_user_id field
|
||||
# 2. Signal user ID in signal_uid field
|
||||
# 3. User ID in phone/mobile fields (legacy - we used to store UUIDs there)
|
||||
customer = nil
|
||||
if sender_phone_number.present?
|
||||
|
|
@ -173,7 +173,7 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
customer ||= User.find_by(mobile: sender_phone_number)
|
||||
end
|
||||
if customer.nil? && sender_user_id.present?
|
||||
customer = User.find_by(signal_user_id: sender_user_id)
|
||||
customer = User.find_by(signal_uid: sender_user_id)
|
||||
# Legacy fallback: user ID might be stored in phone field
|
||||
customer ||= User.find_by(phone: sender_user_id)
|
||||
customer ||= User.find_by(mobile: sender_user_id)
|
||||
|
|
@ -187,7 +187,7 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
email: '',
|
||||
password: '',
|
||||
phone: sender_phone_number.presence || sender_user_id,
|
||||
signal_user_id: sender_user_id,
|
||||
signal_uid: sender_user_id,
|
||||
note: 'CDR Signal',
|
||||
active: true,
|
||||
role_ids: role_ids,
|
||||
|
|
@ -196,9 +196,9 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
)
|
||||
end
|
||||
|
||||
# Update signal_user_id if we have it and customer doesn't
|
||||
if sender_user_id.present? && customer.signal_user_id.blank?
|
||||
customer.update(signal_user_id: sender_user_id)
|
||||
# Update signal_uid if we have it and customer doesn't
|
||||
if sender_user_id.present? && customer.signal_uid.blank?
|
||||
customer.update(signal_uid: sender_user_id)
|
||||
end
|
||||
# Update phone if we have it and customer only has user_id in phone field
|
||||
if sender_phone_number.present? && customer.phone == sender_user_id
|
||||
|
|
@ -282,7 +282,8 @@ class ChannelsCdrSignalController < ApplicationController
|
|||
ticket.state = Ticket::State.find_by(default_follow_up: true) if ticket.state_id != new_state.id
|
||||
else
|
||||
# Set up chat_id based on whether this is a group message
|
||||
chat_id = is_group_message ? receiver_phone_number : (sender_phone_number.presence || sender_user_id)
|
||||
# For direct messages, prefer UUID (more stable than phone numbers which can change)
|
||||
chat_id = is_group_message ? receiver_phone_number : (sender_user_id.presence || sender_phone_number)
|
||||
|
||||
# Build preferences with group_id included if needed
|
||||
cdr_signal_prefs = {
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class ChannelsCdrWhatsappController < ApplicationController
|
|||
|
||||
# Lookup customer with fallback chain:
|
||||
# 1. Phone number in phone/mobile fields (preferred)
|
||||
# 2. WhatsApp user ID in whatsapp_user_id field
|
||||
# 2. WhatsApp user ID in whatsapp_uid field
|
||||
# 3. User ID in phone/mobile fields (legacy - we used to store LIDs there)
|
||||
customer = nil
|
||||
if sender_phone_number.present?
|
||||
|
|
@ -158,7 +158,7 @@ class ChannelsCdrWhatsappController < ApplicationController
|
|||
customer ||= User.find_by(mobile: sender_phone_number)
|
||||
end
|
||||
if customer.nil? && sender_user_id.present?
|
||||
customer = User.find_by(whatsapp_user_id: sender_user_id)
|
||||
customer = User.find_by(whatsapp_uid: sender_user_id)
|
||||
# Legacy fallback: user ID might be stored in phone field
|
||||
customer ||= User.find_by(phone: sender_user_id)
|
||||
customer ||= User.find_by(mobile: sender_user_id)
|
||||
|
|
@ -172,7 +172,7 @@ class ChannelsCdrWhatsappController < ApplicationController
|
|||
email: '',
|
||||
password: '',
|
||||
phone: sender_phone_number.presence || sender_user_id,
|
||||
whatsapp_user_id: sender_user_id,
|
||||
whatsapp_uid: sender_user_id,
|
||||
note: 'CDR Whatsapp',
|
||||
active: true,
|
||||
role_ids: role_ids,
|
||||
|
|
@ -181,9 +181,9 @@ class ChannelsCdrWhatsappController < ApplicationController
|
|||
)
|
||||
end
|
||||
|
||||
# Update whatsapp_user_id if we have it and customer doesn't
|
||||
if sender_user_id.present? && customer.whatsapp_user_id.blank?
|
||||
customer.update(whatsapp_user_id: sender_user_id)
|
||||
# Update whatsapp_uid if we have it and customer doesn't
|
||||
if sender_user_id.present? && customer.whatsapp_uid.blank?
|
||||
customer.update(whatsapp_uid: sender_user_id)
|
||||
end
|
||||
# Update phone if we have it and customer only has user_id in phone field
|
||||
if sender_phone_number.present? && customer.phone == sender_user_id
|
||||
|
|
|
|||
|
|
@ -1,25 +1,123 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMessagingUserIds < ActiveRecord::Migration[5.2]
|
||||
def self.up
|
||||
# Add WhatsApp user ID field (LID - Linked ID in Baileys 7+)
|
||||
unless column_exists?(:users, :whatsapp_user_id)
|
||||
add_column :users, :whatsapp_user_id, :string, limit: 50
|
||||
add_index :users, :whatsapp_user_id
|
||||
# Add WhatsApp UID column
|
||||
unless column_exists?(:users, :whatsapp_uid)
|
||||
add_column :users, :whatsapp_uid, :string, limit: 50
|
||||
add_index :users, :whatsapp_uid
|
||||
end
|
||||
User.reset_column_information
|
||||
|
||||
# Add Signal user ID field (UUID)
|
||||
unless column_exists?(:users, :signal_user_id)
|
||||
add_column :users, :signal_user_id, :string, limit: 50
|
||||
add_index :users, :signal_user_id
|
||||
# Add Signal UID column
|
||||
unless column_exists?(:users, :signal_uid)
|
||||
add_column :users, :signal_uid, :string, limit: 50
|
||||
add_index :users, :signal_uid
|
||||
end
|
||||
User.reset_column_information
|
||||
|
||||
# Register WhatsApp UID with ObjectManager for UI
|
||||
# Column name: whatsapp_uid, Display name: "WhatsApp User ID"
|
||||
ObjectManager::Attribute.add(
|
||||
force: true,
|
||||
object: 'User',
|
||||
name: 'whatsapp_uid',
|
||||
display: 'WhatsApp User ID',
|
||||
data_type: 'input',
|
||||
data_option: {
|
||||
type: 'text',
|
||||
maxlength: 50,
|
||||
null: true,
|
||||
item_class: 'formGroup--halfSize',
|
||||
},
|
||||
editable: false,
|
||||
active: true,
|
||||
screens: {
|
||||
signup: {},
|
||||
invite_agent: {},
|
||||
invite_customer: {},
|
||||
edit: {
|
||||
'-all-' => {
|
||||
null: true,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
'-all-' => {
|
||||
null: true,
|
||||
},
|
||||
},
|
||||
view: {
|
||||
'-all-' => {
|
||||
shown: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
to_create: false,
|
||||
to_migrate: false,
|
||||
to_delete: false,
|
||||
position: 710,
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
)
|
||||
|
||||
# Register Signal UID with ObjectManager for UI
|
||||
# Column name: signal_uid, Display name: "Signal User ID"
|
||||
ObjectManager::Attribute.add(
|
||||
force: true,
|
||||
object: 'User',
|
||||
name: 'signal_uid',
|
||||
display: 'Signal User ID',
|
||||
data_type: 'input',
|
||||
data_option: {
|
||||
type: 'text',
|
||||
maxlength: 50,
|
||||
null: true,
|
||||
item_class: 'formGroup--halfSize',
|
||||
},
|
||||
editable: false,
|
||||
active: true,
|
||||
screens: {
|
||||
signup: {},
|
||||
invite_agent: {},
|
||||
invite_customer: {},
|
||||
edit: {
|
||||
'-all-' => {
|
||||
null: true,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
'-all-' => {
|
||||
null: true,
|
||||
},
|
||||
},
|
||||
view: {
|
||||
'-all-' => {
|
||||
shown: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
to_create: false,
|
||||
to_migrate: false,
|
||||
to_delete: false,
|
||||
position: 720,
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
)
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :users, :whatsapp_user_id if index_exists?(:users, :whatsapp_user_id)
|
||||
remove_column :users, :whatsapp_user_id if column_exists?(:users, :whatsapp_user_id)
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'User',
|
||||
name: 'whatsapp_uid',
|
||||
)
|
||||
|
||||
remove_index :users, :signal_user_id if index_exists?(:users, :signal_user_id)
|
||||
remove_column :users, :signal_user_id if column_exists?(:users, :signal_user_id)
|
||||
ObjectManager::Attribute.remove(
|
||||
object: 'User',
|
||||
name: 'signal_uid',
|
||||
)
|
||||
|
||||
remove_index :users, :whatsapp_uid if index_exists?(:users, :whatsapp_uid)
|
||||
remove_column :users, :whatsapp_uid if column_exists?(:users, :whatsapp_uid)
|
||||
|
||||
remove_index :users, :signal_uid if index_exists?(:users, :signal_uid)
|
||||
remove_column :users, :signal_uid if column_exists?(:users, :signal_uid)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-common",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "",
|
||||
"bin": {
|
||||
"zpm-build": "./dist/build.js",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@link-stack/zammad-addon-hardening",
|
||||
"displayName": "Hardening",
|
||||
"version": "3.4.0-beta.5",
|
||||
"version": "3.4.0-beta.6",
|
||||
"description": "A Zammad addon that hardens a Zammad instance according to CDR's needs.",
|
||||
"scripts": {
|
||||
"build": "node '../zammad-addon-common/dist/build.js'",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue