Whatsapp unlink and channel display fixes
This commit is contained in:
parent
2fbe8ac75a
commit
b179ae5069
7 changed files with 42 additions and 20 deletions
|
|
@ -9,6 +9,7 @@ services:
|
|||
environment:
|
||||
PORT: 5000
|
||||
NODE_ENV: production
|
||||
BRIDGE_FRONTEND_URL: http://link:3000/link
|
||||
volumes:
|
||||
- bridge-whatsapp-data:/home/node/baileys
|
||||
ports:
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ x-bridge-vars: &common-bridge-variables
|
|||
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
|
||||
BRIDGE_SIGNAL_URL: ${BRIDGE_SIGNAL_URL}
|
||||
BRIDGE_SIGNAL_AUTO_GROUPS: ${BRIDGE_SIGNAL_AUTO_GROUPS}
|
||||
BRIDGE_WHATSAPP_URL: "http://bridge-whatsapp:5000"
|
||||
LOG_LEVEL: "debug"
|
||||
ZAMMAD_API_TOKEN: ${ZAMMAD_API_TOKEN}
|
||||
ZAMMAD_URL: ${ZAMMAD_URL}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ services:
|
|||
LINK_URL: ${LINK_URL}
|
||||
BRIDGE_URL: http://bridge-frontend:3000
|
||||
BRIDGE_SIGNAL_URL: http://signal-cli-rest-api:8080
|
||||
BRIDGE_WHATSAPP_URL: http://bridge-whatsapp:3000
|
||||
BRIDGE_WHATSAPP_URL: http://bridge-whatsapp:5000
|
||||
ZAMMAD_URL: http://zammad-nginx:8080
|
||||
REDIS_URL: "redis://zammad-redis:6379"
|
||||
NEXTAUTH_URL: ${LINK_URL}/api/auth
|
||||
|
|
|
|||
|
|
@ -29,21 +29,30 @@ export const QRCode: FC<QRCodeProps> = ({
|
|||
|
||||
useEffect(() => {
|
||||
if (!verified && getValue && refreshInterval) {
|
||||
const interval = setInterval(async () => {
|
||||
// Fetch immediately on mount
|
||||
const fetchQR = async () => {
|
||||
const { qr, kind } = await getValue(token);
|
||||
setValue(qr);
|
||||
setKind(kind);
|
||||
}, refreshInterval * 1000);
|
||||
};
|
||||
fetchQR();
|
||||
|
||||
// Then set up interval for refreshes
|
||||
const interval = setInterval(fetchQR, refreshInterval * 1000);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
}, [getValue, refreshInterval]);
|
||||
}, [getValue, refreshInterval, token, verified]);
|
||||
|
||||
return !verified ? (
|
||||
<Box sx={{ backgroundColor: white, m: 2 }}>
|
||||
{kind === "data" ? (
|
||||
<QRCodeInternal value={value} />
|
||||
{value ? (
|
||||
kind === "data" ? (
|
||||
<QRCodeInternal value={value} />
|
||||
) : (
|
||||
<img src={value} alt={name} />
|
||||
)
|
||||
) : (
|
||||
<img src={value} alt={name} />
|
||||
<Box>Loading QR code...</Box>
|
||||
)}
|
||||
<Box>{helperText}</Box>
|
||||
</Box>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,28 @@ import { ServiceConfig } from "../lib/service";
|
|||
// import { generateSelectOneAction } from "../lib/actions";
|
||||
|
||||
const getQRCode = async (token: string) => {
|
||||
const url = `/link/api/whatsapp/bots/${token}`;
|
||||
const result = await fetch(url, { cache: "no-store" });
|
||||
const { qr } = await result.json();
|
||||
try {
|
||||
const url = `/link/api/whatsapp/bots/${token}`;
|
||||
const result = await fetch(url, { cache: "no-store" });
|
||||
|
||||
return { qr, kind: "data" };
|
||||
if (!result.ok) {
|
||||
console.error(`Failed to fetch QR code: ${result.status} ${result.statusText}`);
|
||||
return { qr: "", kind: "data" };
|
||||
}
|
||||
|
||||
const data = await result.json();
|
||||
const { qr } = data;
|
||||
|
||||
if (!qr) {
|
||||
console.error("No QR code in response");
|
||||
return { qr: "", kind: "data" };
|
||||
}
|
||||
|
||||
return { qr, kind: "data" };
|
||||
} catch (error) {
|
||||
console.error("Error fetching QR code:", error);
|
||||
return { qr: "", kind: "data" };
|
||||
}
|
||||
};
|
||||
|
||||
export const whatsappConfig: ServiceConfig = {
|
||||
|
|
|
|||
|
|
@ -45,13 +45,6 @@ class CdrWhatsappReply
|
|||
@articleTypes: (articleTypes, ticket, ui) ->
|
||||
return articleTypes if !ui.permissionCheck('ticket.agent')
|
||||
|
||||
# Check CDR Link allowed channels setting
|
||||
allowedChannels = ui.Config.get('cdr_link_allowed_channels')
|
||||
if allowedChannels && allowedChannels.trim()
|
||||
whitelist = (channel.trim() for channel in allowedChannels.split(','))
|
||||
# Return early if 'cdr_whatsapp' or 'whatsapp message' not in whitelist
|
||||
return articleTypes if 'cdr_whatsapp' not in whitelist && 'whatsapp message' not in whitelist
|
||||
|
||||
return articleTypes if !ticket || !ticket.create_article_type_id
|
||||
|
||||
articleTypeCreate = App.TicketArticleType.find(ticket.create_article_type_id).name
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ require '/opt/zammad/config/application'
|
|||
|
||||
Rails.application.initialize!
|
||||
|
||||
Setting.set('cdr_link_allowed_channels', 'note,cdr_signal,email')
|
||||
puts "Setting 'cdr_link_allowed_channels' has been set to: 'note,cdr_signal,email'"
|
||||
# Reset to default (empty = allow all channels)
|
||||
Setting.set('cdr_link_allowed_channels', '')
|
||||
puts "Setting 'cdr_link_allowed_channels' has been reset to default (empty = allow all channels)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue