Compare commits
200
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6f6263f3c | ||
|
|
5f03418ac9 | ||
|
|
11370316b2 | ||
|
|
9a09df4563 | ||
|
|
364dbdd69f | ||
|
|
f1832148fd | ||
|
|
8f9c45ea8c | ||
|
|
24c7171a4e | ||
|
|
b5f3daafc9 | ||
|
|
2c204326e5 | ||
|
|
a33ae58452 | ||
|
|
a96e75b904 | ||
|
|
5bb88192c4 | ||
|
|
6475a6a593 | ||
|
|
441cc065ae | ||
|
|
0b74be82a3 | ||
|
|
cbc2807296 | ||
|
|
c09e875c83 | ||
|
|
87313ecc35 | ||
|
|
8262123481 | ||
|
|
420be64c45 | ||
|
|
9acb0d86b5 | ||
|
|
2a5ecf84a1 | ||
|
|
286e3a449d | ||
|
|
e5ee6027b4 | ||
|
|
eb412b67bd | ||
|
|
6fb762f96c | ||
|
|
ab1ba1c4c7 | ||
|
|
d276025419 | ||
|
|
94b7154926 | ||
|
|
60951b45fd | ||
|
|
69ad953ae6 | ||
|
|
c4b076dbb2 | ||
|
|
dc49ae2515 | ||
|
|
b71a0da10d | ||
|
|
bb9e3a5495 | ||
|
|
647a65d481 | ||
|
|
99ec18c95b | ||
|
|
64ba23688b | ||
|
|
2fec2e5993 | ||
|
|
090316a078 | ||
|
|
fcd604dcde | ||
|
|
13b4fdb34c | ||
|
|
45d4d3660c | ||
|
|
0ea616a6ea | ||
|
|
6b8dd3c86a | ||
|
|
61d10044a0 | ||
|
|
4378506a35 | ||
|
|
1132556512 | ||
|
|
93f18315cc | ||
|
|
d89fa09359 | ||
|
|
07dd6448f4 | ||
|
|
661326ae51 | ||
|
|
18eb53acf4 | ||
|
|
1b02ebec68 | ||
|
|
5b9f997fa0 | ||
|
|
802f0694ed | ||
|
|
17500cc62d | ||
|
|
5140deb6f6 | ||
|
|
3e5ca9bca9 | ||
|
|
5ebe8c71ec | ||
|
|
8c78573d9d | ||
|
|
c553997af8 | ||
|
|
30a3a35281 | ||
|
|
e4ba80e2f0 | ||
|
|
b72848513f | ||
|
|
b8814a8bd5 | ||
|
|
3e993ead0f | ||
|
|
7343e53659 | ||
|
|
cb01a2bc66 | ||
|
|
4e4aa7f580 | ||
|
|
a6cc3617c0 | ||
|
|
3ea6429895 | ||
|
|
19d8f6bac5 | ||
|
|
cdb1dc6714 | ||
|
|
ef591f848a | ||
|
|
20dc4f169c | ||
|
|
01acbe3cda | ||
|
|
14ba73fc63 | ||
|
|
2573f37d90 | ||
|
|
d1c9af260c | ||
|
|
24ea968b00 | ||
|
|
58da92a252 | ||
|
|
a657b45bd1 | ||
|
|
6e207acb5a | ||
|
|
d7c10b4f2a | ||
|
|
b1893c7d96 | ||
|
|
ee4a0d4486 | ||
|
|
eea1ab3002 | ||
|
|
b7f3f72b9c | ||
|
|
b26862e3d8 | ||
|
|
811eb66615 | ||
|
|
257cd07ee6 | ||
|
|
b7f2c151bf | ||
|
|
97efd36bc5 | ||
|
|
a0bf6055fc | ||
|
|
c42dd8a23e | ||
|
|
cc8866a84e | ||
|
|
92c51a10de | ||
|
|
9edfb1e902 | ||
|
|
be6bc88f80 | ||
|
|
ea4477ccde | ||
|
|
a2857cac38 | ||
|
|
293a29ec98 | ||
|
|
ddada56753 | ||
|
|
578e2ee8db | ||
|
|
b683973e79 | ||
|
|
2cfca6008b | ||
|
|
d2f5311400 | ||
|
|
f6dbbf0d90 | ||
|
|
768fa9ab1b | ||
|
|
89bcef4623 | ||
|
|
25a0c9ed91 | ||
|
|
dc77b5bb2b | ||
|
|
5487d4c615 | ||
|
|
b4b2b0bdc2 | ||
|
|
16dbcabaac | ||
|
|
b87b7972c1 | ||
|
|
149dab239a | ||
|
|
f4381e3b5d | ||
|
|
58380c6d01 | ||
|
|
e54e80a936 | ||
|
|
ac3bce3932 | ||
|
|
6baca40597 | ||
|
|
f28bb70d67 | ||
|
|
288df3a399 | ||
|
|
d52f4267ba | ||
|
|
0d05a07aa7 | ||
|
|
c8f5633d9d | ||
|
|
bf3b1676dd | ||
|
|
f627dbe42d | ||
|
|
5745a55db5 | ||
|
|
68bfbc7eb0 | ||
|
|
7a67799f35 | ||
|
|
459c22054a | ||
|
|
35f06f30e7 | ||
|
|
c0d9533b3a | ||
|
|
4303007786 | ||
|
|
4a83e70158 | ||
|
|
53e2585275 | ||
|
|
9b8c8a3850 | ||
|
|
07d3b92b12 | ||
|
|
c710cbe370 | ||
|
|
cf1d0de294 | ||
|
|
3e73c1b4bc | ||
|
|
25f947223d | ||
|
|
9b43a0f72b | ||
|
|
10363e77ad | ||
|
|
27bce50210 | ||
|
|
8bc00f707b | ||
|
|
273c277d47 | ||
|
|
4c0d096e4d | ||
|
|
2f40f95f77 | ||
|
|
ee293c3598 | ||
|
|
513d954027 | ||
|
|
e9a132a923 | ||
|
|
b70d2c0ebe | ||
|
|
623734a631 | ||
|
|
b81f1bc971 | ||
|
|
ff0ad53f49 | ||
|
|
02c4863d95 | ||
|
|
bae958334d | ||
|
|
a5fda8e118 | ||
|
|
8fa039e1c5 | ||
|
|
4061f99114 | ||
|
|
f064b09776 | ||
|
|
07a39f4b42 | ||
|
|
8bbf6c75e3 | ||
|
|
aad6d655d5 | ||
|
|
70c29f699c | ||
|
|
4ab0b17e6e | ||
|
|
3548948c92 | ||
|
|
b1898e019b | ||
|
|
b3a76289cc | ||
|
|
873cfa08d8 | ||
|
|
a0cc27faaf | ||
|
|
fdd35ff549 | ||
|
|
2ea10ae065 | ||
|
|
23a804512a | ||
|
|
f6510e0d43 | ||
|
|
c3d98fc064 | ||
|
|
b5ebc47637 | ||
|
|
f916fb2924 | ||
|
|
dc335e88c9 | ||
|
|
b1120ae7fb | ||
|
|
443214e9a0 | ||
|
|
3ce026e2bc | ||
|
|
f42fddd38e | ||
|
|
22b5e12a53 | ||
|
|
03bde0a8aa | ||
|
|
3a0b5f387d | ||
|
|
9bd658137a | ||
|
|
f73c5ef0b8 | ||
|
|
f9fce5e2df | ||
|
|
c2d8e2ad77 | ||
|
|
03c0a7c62e | ||
|
|
d40a59f7fa | ||
|
|
72c5671e09 | ||
|
|
8c0885e1d2 | ||
|
|
e92f72b318 |
@@ -1,62 +0,0 @@
|
|||||||
version: '2'
|
|
||||||
plugins:
|
|
||||||
rubocop:
|
|
||||||
enabled: false
|
|
||||||
channel: rubocop-0-73
|
|
||||||
eslint:
|
|
||||||
enabled: false
|
|
||||||
csslint:
|
|
||||||
enabled: true
|
|
||||||
scss-lint:
|
|
||||||
enabled: true
|
|
||||||
brakeman:
|
|
||||||
enabled: false
|
|
||||||
checks:
|
|
||||||
similar-code:
|
|
||||||
enabled: false
|
|
||||||
method-count:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
threshold: 32
|
|
||||||
file-lines:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
threshold: 300
|
|
||||||
method-lines:
|
|
||||||
config:
|
|
||||||
threshold: 50
|
|
||||||
exclude_patterns:
|
|
||||||
- 'spec/'
|
|
||||||
- '**/specs/**/**'
|
|
||||||
- '**/spec/**/**'
|
|
||||||
- 'db/*'
|
|
||||||
- 'bin/**/*'
|
|
||||||
- 'db/**/*'
|
|
||||||
- 'config/**/*'
|
|
||||||
- 'public/**/*'
|
|
||||||
- 'vendor/**/*'
|
|
||||||
- 'node_modules/**/*'
|
|
||||||
- 'lib/tasks/auto_annotate_models.rake'
|
|
||||||
- 'app/test-matchers.js'
|
|
||||||
- 'docs/*'
|
|
||||||
- '**/*.md'
|
|
||||||
- '**/*.yml'
|
|
||||||
- 'app/javascript/dashboard/i18n/locale'
|
|
||||||
- '**/*.stories.js'
|
|
||||||
- 'stories/'
|
|
||||||
- 'app/javascript/dashboard/components/widgets/conversation/advancedFilterItems/index.js'
|
|
||||||
- 'app/javascript/shared/constants/countries.js'
|
|
||||||
- 'app/javascript/dashboard/components/widgets/conversation/advancedFilterItems/languages.js'
|
|
||||||
- 'app/javascript/dashboard/routes/dashboard/contacts/contactFilterItems/index.js'
|
|
||||||
- 'app/javascript/dashboard/routes/dashboard/settings/automation/constants.js'
|
|
||||||
- 'app/javascript/dashboard/components/widgets/FilterInput/FilterOperatorTypes.js'
|
|
||||||
- 'app/javascript/dashboard/routes/dashboard/settings/reports/constants.js'
|
|
||||||
- 'app/javascript/dashboard/store/captain/storeFactory.js'
|
|
||||||
- 'app/javascript/dashboard/i18n/index.js'
|
|
||||||
- 'app/javascript/widget/i18n/index.js'
|
|
||||||
- 'app/javascript/survey/i18n/index.js'
|
|
||||||
- 'app/javascript/shared/constants/locales.js'
|
|
||||||
- 'app/javascript/dashboard/helper/specs/macrosFixtures.js'
|
|
||||||
- 'app/javascript/dashboard/routes/dashboard/settings/macros/constants.js'
|
|
||||||
- '**/fixtures/**'
|
|
||||||
- '**/*/fixtures.js'
|
|
||||||
@@ -4,5 +4,15 @@ FROM ghcr.io/chatwoot/chatwoot_codespace:latest
|
|||||||
|
|
||||||
# Do the set up required for chatwoot app
|
# Do the set up required for chatwoot app
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
# Copy dependency files first for better caching
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
COPY Gemfile Gemfile.lock ./
|
||||||
|
|
||||||
|
# Install dependencies (will be cached if files don't change)
|
||||||
|
RUN pnpm install --frozen-lockfile && \
|
||||||
|
gem install bundler && \
|
||||||
|
bundle install --jobs=$(nproc)
|
||||||
|
|
||||||
|
# Copy source code after dependencies are installed
|
||||||
COPY . /workspace
|
COPY . /workspace
|
||||||
RUN yarn && gem install bundler && bundle install
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
|
ARG VARIANT="ubuntu-22.04"
|
||||||
ARG VARIANT
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
|
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
ARG NODE_VERSION
|
ARG NODE_VERSION
|
||||||
ARG RUBY_VERSION
|
ARG RUBY_VERSION
|
||||||
ARG USER_UID
|
ARG USER_UID
|
||||||
ARG USER_GID
|
ARG USER_GID
|
||||||
|
ARG PNPM_VERSION="10.2.0"
|
||||||
|
ENV PNPM_VERSION ${PNPM_VERSION}
|
||||||
|
ENV RUBY_CONFIGURE_OPTS=--disable-install-doc
|
||||||
|
|
||||||
# Update args in docker-compose.yaml to set the UID/GID of the "vscode" user.
|
# Update args in docker-compose.yaml to set the UID/GID of the "vscode" user.
|
||||||
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
|
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
|
||||||
@@ -15,61 +19,80 @@ RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
|
|||||||
&& chmod -R $USER_UID:$USER_GID /home/vscode; \
|
&& chmod -R $USER_UID:$USER_GID /home/vscode; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
RUN NODE_MAJOR=$(echo $NODE_VERSION | cut -d. -f1) \
|
||||||
&& apt-get -y install --no-install-recommends \
|
&& curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \
|
||||||
build-essential \
|
&& apt-get update \
|
||||||
libssl-dev \
|
&& apt-get -y install --no-install-recommends \
|
||||||
zlib1g-dev \
|
build-essential \
|
||||||
gnupg2 \
|
libssl-dev \
|
||||||
tar \
|
zlib1g-dev \
|
||||||
tzdata \
|
gnupg \
|
||||||
postgresql-client \
|
tar \
|
||||||
libpq-dev \
|
tzdata \
|
||||||
yarn \
|
postgresql-client \
|
||||||
git \
|
libpq-dev \
|
||||||
imagemagick \
|
git \
|
||||||
tmux \
|
imagemagick \
|
||||||
zsh \
|
libyaml-dev \
|
||||||
git-flow \
|
curl \
|
||||||
npm \
|
ca-certificates \
|
||||||
libyaml-dev
|
tmux \
|
||||||
|
nodejs \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
# Install rbenv and ruby
|
# Install rbenv and ruby for root user first
|
||||||
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv \
|
RUN git clone --depth 1 https://github.com/rbenv/rbenv.git ~/.rbenv \
|
||||||
&& echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc \
|
&& echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc \
|
||||||
&& echo 'eval "$(rbenv init -)"' >> ~/.bashrc
|
&& echo 'eval "$(rbenv init -)"' >> ~/.bashrc
|
||||||
ENV PATH "/root/.rbenv/bin/:/root/.rbenv/shims/:$PATH"
|
ENV PATH "/root/.rbenv/bin/:/root/.rbenv/shims/:$PATH"
|
||||||
RUN git clone https://github.com/rbenv/ruby-build.git && \
|
RUN git clone --depth 1 https://github.com/rbenv/ruby-build.git && \
|
||||||
PREFIX=/usr/local ./ruby-build/install.sh
|
PREFIX=/usr/local ./ruby-build/install.sh
|
||||||
|
|
||||||
RUN rbenv install $RUBY_VERSION && \
|
RUN rbenv install $RUBY_VERSION && \
|
||||||
rbenv global $RUBY_VERSION && \
|
rbenv global $RUBY_VERSION && \
|
||||||
rbenv versions
|
rbenv versions
|
||||||
|
|
||||||
# Install overmind
|
# Set up rbenv for vscode user
|
||||||
|
RUN su - vscode -c "git clone --depth 1 https://github.com/rbenv/rbenv.git ~/.rbenv" \
|
||||||
|
&& su - vscode -c "echo 'export PATH=\"\$HOME/.rbenv/bin:\$PATH\"' >> ~/.bashrc" \
|
||||||
|
&& su - vscode -c "echo 'eval \"\$(rbenv init -)\"' >> ~/.bashrc" \
|
||||||
|
&& su - vscode -c "PATH=\"/home/vscode/.rbenv/bin:\$PATH\" rbenv install $RUBY_VERSION" \
|
||||||
|
&& su - vscode -c "PATH=\"/home/vscode/.rbenv/bin:\$PATH\" rbenv global $RUBY_VERSION"
|
||||||
|
|
||||||
|
# Install overmind and gh in single layer
|
||||||
RUN curl -L https://github.com/DarthSim/overmind/releases/download/v2.1.0/overmind-v2.1.0-linux-amd64.gz > overmind.gz \
|
RUN curl -L https://github.com/DarthSim/overmind/releases/download/v2.1.0/overmind-v2.1.0-linux-amd64.gz > overmind.gz \
|
||||||
&& gunzip overmind.gz \
|
&& gunzip overmind.gz \
|
||||||
&& sudo mv overmind /usr/local/bin \
|
&& mv overmind /usr/local/bin \
|
||||||
&& chmod +x /usr/local/bin/overmind
|
&& chmod +x /usr/local/bin/overmind \
|
||||||
|
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
||||||
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
||||||
# Install gh
|
&& apt-get update \
|
||||||
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
&& apt-get install -y --no-install-recommends gh \
|
||||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
&& apt-get clean \
|
||||||
&& sudo apt update \
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
&& sudo apt install gh
|
|
||||||
|
|
||||||
|
|
||||||
# Do the set up required for chatwoot app
|
# Do the set up required for chatwoot app
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
COPY . /workspace
|
RUN chown vscode:vscode /workspace
|
||||||
|
|
||||||
# set up ruby
|
# set up node js, pnpm and claude code in single layer
|
||||||
COPY Gemfile Gemfile.lock ./
|
RUN npm install -g pnpm@${PNPM_VERSION} @anthropic-ai/claude-code \
|
||||||
RUN gem install bundler && bundle install
|
&& npm cache clean --force
|
||||||
|
|
||||||
# set up node js
|
# Switch to vscode user
|
||||||
RUN npm install n -g && \
|
USER vscode
|
||||||
n $NODE_VERSION
|
ENV PATH="/home/vscode/.rbenv/bin:/home/vscode/.rbenv/shims:$PATH"
|
||||||
RUN npm install --global yarn
|
|
||||||
RUN yarn
|
# Copy dependency files first for better caching
|
||||||
|
COPY --chown=vscode:vscode Gemfile Gemfile.lock package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
# Install dependencies as vscode user
|
||||||
|
RUN eval "$(rbenv init -)" \
|
||||||
|
&& gem install bundler -N \
|
||||||
|
&& bundle install --jobs=$(nproc) \
|
||||||
|
&& pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy source code after dependencies are installed
|
||||||
|
COPY --chown=vscode:vscode . /workspace
|
||||||
|
|||||||
@@ -4,17 +4,26 @@
|
|||||||
"dockerComposeFile": "docker-compose.yml",
|
"dockerComposeFile": "docker-compose.yml",
|
||||||
|
|
||||||
"settings": {
|
"settings": {
|
||||||
"terminal.integrated.shell.linux": "/bin/zsh"
|
"terminal.integrated.shell.linux": "/bin/zsh",
|
||||||
|
"extensions.showRecommendationsOnlyOnDemand": true,
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"files.trimTrailingWhitespace": true,
|
||||||
|
"files.insertFinalNewline": true,
|
||||||
|
"search.exclude": {
|
||||||
|
"**/node_modules": true,
|
||||||
|
"**/tmp": true,
|
||||||
|
"**/log": true,
|
||||||
|
"**/coverage": true,
|
||||||
|
"**/public/packs": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"rebornix.Ruby",
|
"Shopify.ruby-lsp",
|
||||||
"misogi.ruby-rubocop",
|
"misogi.ruby-rubocop",
|
||||||
"wingrunr21.vscode-ruby",
|
|
||||||
"davidpallinder.rails-test-runner",
|
"davidpallinder.rails-test-runner",
|
||||||
"eamodio.gitlens",
|
|
||||||
"github.copilot",
|
"github.copilot",
|
||||||
"mrmlnc.vscode-duplicate"
|
"mrmlnc.vscode-duplicate"
|
||||||
],
|
],
|
||||||
@@ -23,15 +32,15 @@
|
|||||||
// 5432 postgres
|
// 5432 postgres
|
||||||
// 6379 redis
|
// 6379 redis
|
||||||
// 1025,8025 mailhog
|
// 1025,8025 mailhog
|
||||||
"forwardPorts": [8025, 3000, 3035],
|
"forwardPorts": [8025, 3000, 3036],
|
||||||
|
|
||||||
"postCreateCommand": ".devcontainer/scripts/setup.sh && POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rake db:chatwoot_prepare && yarn",
|
"postCreateCommand": ".devcontainer/scripts/setup.sh && POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rake db:chatwoot_prepare && pnpm install",
|
||||||
"portsAttributes": {
|
"portsAttributes": {
|
||||||
"3000": {
|
"3000": {
|
||||||
"label": "Rails Server"
|
"label": "Rails Server"
|
||||||
},
|
},
|
||||||
"3035": {
|
"3036": {
|
||||||
"label": "Webpack Dev Server"
|
"label": "Vite Dev Server"
|
||||||
},
|
},
|
||||||
"8025": {
|
"8025": {
|
||||||
"label": "Mailhog UI"
|
"label": "Mailhog UI"
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Docker Compose file for building the base image in GitHub Actions
|
||||||
|
# Usage: docker-compose -f .devcontainer/docker-compose.base.yml build base
|
||||||
|
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
base:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: .devcontainer/Dockerfile.base
|
||||||
|
args:
|
||||||
|
VARIANT: 'ubuntu-22.04'
|
||||||
|
NODE_VERSION: '23.7.0'
|
||||||
|
RUBY_VERSION: '3.4.4'
|
||||||
|
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
|
||||||
|
USER_UID: '1000'
|
||||||
|
USER_GID: '1000'
|
||||||
|
image: ghcr.io/chatwoot/chatwoot_codespace:latest
|
||||||
@@ -5,19 +5,6 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
base:
|
|
||||||
build:
|
|
||||||
context: ..
|
|
||||||
dockerfile: .devcontainer/Dockerfile.base
|
|
||||||
args:
|
|
||||||
VARIANT: 'ubuntu-22.04'
|
|
||||||
NODE_VERSION: '23.7.0'
|
|
||||||
RUBY_VERSION: '3.4.4'
|
|
||||||
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
|
|
||||||
USER_UID: '1000'
|
|
||||||
USER_GID: '1000'
|
|
||||||
image: base:latest
|
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ cp .env.example .env
|
|||||||
sed -i -e '/REDIS_URL/ s/=.*/=redis:\/\/localhost:6379/' .env
|
sed -i -e '/REDIS_URL/ s/=.*/=redis:\/\/localhost:6379/' .env
|
||||||
sed -i -e '/POSTGRES_HOST/ s/=.*/=localhost/' .env
|
sed -i -e '/POSTGRES_HOST/ s/=.*/=localhost/' .env
|
||||||
sed -i -e '/SMTP_ADDRESS/ s/=.*/=localhost/' .env
|
sed -i -e '/SMTP_ADDRESS/ s/=.*/=localhost/' .env
|
||||||
sed -i -e "/FRONTEND_URL/ s/=.*/=https:\/\/$CODESPACE_NAME-3000.githubpreview.dev/" .env
|
sed -i -e "/FRONTEND_URL/ s/=.*/=https:\/\/$CODESPACE_NAME-3000.app.github.dev/" .env
|
||||||
sed -i -e "/WEBPACKER_DEV_SERVER_PUBLIC/ s/=.*/=https:\/\/$CODESPACE_NAME-3035.githubpreview.dev/" .env
|
|
||||||
# uncomment the webpacker env variable
|
# Setup Claude Code API key if available
|
||||||
sed -i -e '/WEBPACKER_DEV_SERVER_PUBLIC/s/^# //' .env
|
if [ -n "$CLAUDE_CODE_API_KEY" ]; then
|
||||||
# fix the error with webpacker
|
mkdir -p ~/.claude
|
||||||
echo 'export NODE_OPTIONS=--openssl-legacy-provider' >> ~/.zshrc
|
echo '{"apiKeyHelper": "~/.claude/anthropic_key.sh"}' > ~/.claude/settings.json
|
||||||
|
echo "echo \"$CLAUDE_CODE_API_KEY\"" > ~/.claude/anthropic_key.sh
|
||||||
|
chmod +x ~/.claude/anthropic_key.sh
|
||||||
|
fi
|
||||||
|
|
||||||
# codespaces make the ports public
|
# codespaces make the ports public
|
||||||
gh codespace ports visibility 3000:public 3035:public 8025:public -c $CODESPACE_NAME
|
gh codespace ports visibility 3000:public 3036:public 8025:public -c $CODESPACE_NAME
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ module.exports = {
|
|||||||
'⌘',
|
'⌘',
|
||||||
'📄',
|
'📄',
|
||||||
'🎉',
|
'🎉',
|
||||||
|
'🚀',
|
||||||
'💬',
|
'💬',
|
||||||
'👥',
|
'👥',
|
||||||
'📥',
|
'📥',
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
name: Auto-assign PR to Author
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
auto-assign:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
steps:
|
||||||
|
- name: Auto-assign PR to author
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
const pull_number = context.payload.pull_request.number;
|
||||||
|
const author = context.payload.pull_request.user.login;
|
||||||
|
|
||||||
|
await github.rest.issues.addAssignees({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: pull_number,
|
||||||
|
assignees: [author]
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Assigned PR #${pull_number} to ${author}`);
|
||||||
@@ -6,6 +6,11 @@ name: Deploy Check
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
# If two pushes happen within a short time in the same PR, cancel the run of the oldest push
|
||||||
|
concurrency:
|
||||||
|
group: pr-${{ github.workflow }}-${{ github.head_ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deployment_check:
|
deployment_check:
|
||||||
name: Check Deployment
|
name: Check Deployment
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- develop
|
- develop
|
||||||
|
|
||||||
|
# If two pushes happen within a short time in the same PR, cancel the run of the oldest push
|
||||||
|
concurrency:
|
||||||
|
group: pr-${{ github.workflow }}-${{ github.head_ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
log_lines_check:
|
log_lines_check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -19,6 +19,5 @@ jobs:
|
|||||||
|
|
||||||
- name: Build the Codespace Base Image
|
- name: Build the Codespace Base Image
|
||||||
run: |
|
run: |
|
||||||
docker-compose -f .devcontainer/docker-compose.yml build base
|
docker compose -f .devcontainer/docker-compose.base.yml build base
|
||||||
docker tag base:latest ghcr.io/chatwoot/chatwoot_codespace:latest
|
|
||||||
docker push ghcr.io/chatwoot/chatwoot_codespace:latest
|
docker push ghcr.io/chatwoot/chatwoot_codespace:latest
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- develop
|
- develop
|
||||||
|
|
||||||
|
# If two pushes happen within a short time in the same PR, cancel the run of the oldest push
|
||||||
|
concurrency:
|
||||||
|
group: pr-${{ github.workflow }}-${{ github.head_ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
*
|
||||||
|
!configs
|
||||||
|
!configs/**
|
||||||
|
!hooks
|
||||||
|
!hooks/**
|
||||||
|
!qlty.toml
|
||||||
|
!.gitignore
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ignored:
|
||||||
|
- DL3008
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
source-path=SCRIPTDIR
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
rules:
|
||||||
|
document-start: disable
|
||||||
|
quoted-strings:
|
||||||
|
required: only-when-needed
|
||||||
|
extra-allowed: ["{|}"]
|
||||||
|
key-duplicates: {}
|
||||||
|
octal-values:
|
||||||
|
forbid-implicit-octal: true
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# This file was automatically generated by `qlty init`.
|
||||||
|
# You can modify it to suit your needs.
|
||||||
|
# We recommend you to commit this file to your repository.
|
||||||
|
#
|
||||||
|
# This configuration is used by both Qlty CLI and Qlty Cloud.
|
||||||
|
#
|
||||||
|
# Qlty CLI -- Code quality toolkit for developers
|
||||||
|
# Qlty Cloud -- Fully automated Code Health Platform
|
||||||
|
#
|
||||||
|
# Try Qlty Cloud: https://qlty.sh
|
||||||
|
#
|
||||||
|
# For a guide to configuration, visit https://qlty.sh/d/config
|
||||||
|
# Or for a full reference, visit https://qlty.sh/d/qlty-toml
|
||||||
|
config_version = "0"
|
||||||
|
|
||||||
|
exclude_patterns = [
|
||||||
|
"*_min.*",
|
||||||
|
"*-min.*",
|
||||||
|
"*.min.*",
|
||||||
|
"**/.yarn/**",
|
||||||
|
"**/*.d.ts",
|
||||||
|
"**/assets/**",
|
||||||
|
"**/bower_components/**",
|
||||||
|
"**/build/**",
|
||||||
|
"**/cache/**",
|
||||||
|
"**/config/**",
|
||||||
|
"**/db/**",
|
||||||
|
"**/deps/**",
|
||||||
|
"**/dist/**",
|
||||||
|
"**/extern/**",
|
||||||
|
"**/external/**",
|
||||||
|
"**/generated/**",
|
||||||
|
"**/Godeps/**",
|
||||||
|
"**/gradlew/**",
|
||||||
|
"**/mvnw/**",
|
||||||
|
"**/node_modules/**",
|
||||||
|
"**/protos/**",
|
||||||
|
"**/seed/**",
|
||||||
|
"**/target/**",
|
||||||
|
"**/templates/**",
|
||||||
|
"**/testdata/**",
|
||||||
|
"**/vendor/**", "spec/", "**/specs/**/**", "**/spec/**/**", "db/*", "bin/**/*", "db/**/*", "config/**/*", "public/**/*", "vendor/**/*", "node_modules/**/*", "lib/tasks/auto_annotate_models.rake", "app/test-matchers.js", "docs/*", "**/*.md", "**/*.yml", "app/javascript/dashboard/i18n/locale", "**/*.stories.js", "stories/", "app/javascript/dashboard/components/widgets/conversation/advancedFilterItems/index.js", "app/javascript/shared/constants/countries.js", "app/javascript/dashboard/components/widgets/conversation/advancedFilterItems/languages.js", "app/javascript/dashboard/routes/dashboard/contacts/contactFilterItems/index.js", "app/javascript/dashboard/routes/dashboard/settings/automation/constants.js", "app/javascript/dashboard/components/widgets/FilterInput/FilterOperatorTypes.js", "app/javascript/dashboard/routes/dashboard/settings/reports/constants.js", "app/javascript/dashboard/store/captain/storeFactory.js", "app/javascript/dashboard/i18n/index.js", "app/javascript/widget/i18n/index.js", "app/javascript/survey/i18n/index.js", "app/javascript/shared/constants/locales.js", "app/javascript/dashboard/helper/specs/macrosFixtures.js", "app/javascript/dashboard/routes/dashboard/settings/macros/constants.js", "**/fixtures/**", "**/*/fixtures.js",
|
||||||
|
]
|
||||||
|
|
||||||
|
test_patterns = [
|
||||||
|
"**/test/**",
|
||||||
|
"**/spec/**",
|
||||||
|
"**/*.test.*",
|
||||||
|
"**/*.spec.*",
|
||||||
|
"**/*_test.*",
|
||||||
|
"**/*_spec.*",
|
||||||
|
"**/test_*.*",
|
||||||
|
"**/spec_*.*",
|
||||||
|
]
|
||||||
|
|
||||||
|
[smells]
|
||||||
|
mode = "comment"
|
||||||
|
|
||||||
|
[smells.boolean_logic]
|
||||||
|
threshold = 4
|
||||||
|
|
||||||
|
[smells.file_complexity]
|
||||||
|
threshold = 66
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
[smells.return_statements]
|
||||||
|
threshold = 4
|
||||||
|
|
||||||
|
[smells.nested_control_flow]
|
||||||
|
threshold = 4
|
||||||
|
|
||||||
|
[smells.function_parameters]
|
||||||
|
threshold = 4
|
||||||
|
|
||||||
|
[smells.function_complexity]
|
||||||
|
threshold = 5
|
||||||
|
|
||||||
|
[smells.duplication]
|
||||||
|
enabled = true
|
||||||
|
threshold = 20
|
||||||
|
|
||||||
|
[[source]]
|
||||||
|
name = "default"
|
||||||
|
default = true
|
||||||
+1
-1
@@ -283,7 +283,7 @@ Rails/RedundantActiveRecordAllMethod:
|
|||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Layout/TrailingEmptyLines:
|
Layout/TrailingEmptyLines:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Style/SafeNavigationChainLength:
|
Style/SafeNavigationChainLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ gem 'sentry-sidekiq', '>= 5.19.0', require: false
|
|||||||
gem 'sidekiq', '>= 7.3.1'
|
gem 'sidekiq', '>= 7.3.1'
|
||||||
# We want cron jobs
|
# We want cron jobs
|
||||||
gem 'sidekiq-cron', '>= 1.12.0'
|
gem 'sidekiq-cron', '>= 1.12.0'
|
||||||
|
# for sidekiq healthcheck
|
||||||
|
gem 'sidekiq_alive'
|
||||||
|
|
||||||
##-- Push notification service --##
|
##-- Push notification service --##
|
||||||
gem 'fcm'
|
gem 'fcm'
|
||||||
@@ -177,6 +179,7 @@ gem 'reverse_markdown'
|
|||||||
|
|
||||||
gem 'iso-639'
|
gem 'iso-639'
|
||||||
gem 'ruby-openai'
|
gem 'ruby-openai'
|
||||||
|
gem 'ai-agents', '>= 0.2.1'
|
||||||
|
|
||||||
gem 'shopify_api'
|
gem 'shopify_api'
|
||||||
|
|
||||||
|
|||||||
+31
-10
@@ -126,6 +126,8 @@ GEM
|
|||||||
jbuilder (~> 2)
|
jbuilder (~> 2)
|
||||||
rails (>= 4.2, < 7.2)
|
rails (>= 4.2, < 7.2)
|
||||||
selectize-rails (~> 0.6)
|
selectize-rails (~> 0.6)
|
||||||
|
ai-agents (0.2.1)
|
||||||
|
ruby_llm (~> 1.3)
|
||||||
annotate (3.2.0)
|
annotate (3.2.0)
|
||||||
activerecord (>= 3.2, < 8.0)
|
activerecord (>= 3.2, < 8.0)
|
||||||
rake (>= 10.4, < 14.0)
|
rake (>= 10.4, < 14.0)
|
||||||
@@ -172,6 +174,8 @@ GEM
|
|||||||
bundler (>= 1.2.0, < 3)
|
bundler (>= 1.2.0, < 3)
|
||||||
thor (~> 1.0)
|
thor (~> 1.0)
|
||||||
byebug (11.1.3)
|
byebug (11.1.3)
|
||||||
|
childprocess (5.1.0)
|
||||||
|
logger (~> 1.5)
|
||||||
climate_control (1.2.0)
|
climate_control (1.2.0)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
commonmarker (0.23.10)
|
commonmarker (0.23.10)
|
||||||
@@ -355,6 +359,7 @@ GEM
|
|||||||
grpc (1.72.0-x86_64-linux)
|
grpc (1.72.0-x86_64-linux)
|
||||||
google-protobuf (>= 3.25, < 5.0)
|
google-protobuf (>= 3.25, < 5.0)
|
||||||
googleapis-common-protos-types (~> 1.0)
|
googleapis-common-protos-types (~> 1.0)
|
||||||
|
gserver (0.0.1)
|
||||||
haikunator (1.1.1)
|
haikunator (1.1.1)
|
||||||
hairtrigger (1.0.0)
|
hairtrigger (1.0.0)
|
||||||
activerecord (>= 6.0, < 8)
|
activerecord (>= 6.0, < 8)
|
||||||
@@ -433,10 +438,12 @@ GEM
|
|||||||
json (>= 1.8)
|
json (>= 1.8)
|
||||||
rexml
|
rexml
|
||||||
language_server-protocol (3.17.0.5)
|
language_server-protocol (3.17.0.5)
|
||||||
launchy (2.5.2)
|
launchy (3.1.1)
|
||||||
addressable (~> 2.8)
|
addressable (~> 2.8)
|
||||||
letter_opener (1.8.1)
|
childprocess (~> 5.0)
|
||||||
launchy (>= 2.2, < 3)
|
logger (~> 1.6)
|
||||||
|
letter_opener (1.10.0)
|
||||||
|
launchy (>= 2.2, < 4)
|
||||||
line-bot-api (1.28.0)
|
line-bot-api (1.28.0)
|
||||||
lint_roller (1.1.0)
|
lint_roller (1.1.0)
|
||||||
liquid (5.4.0)
|
liquid (5.4.0)
|
||||||
@@ -471,7 +478,7 @@ GEM
|
|||||||
mime-types-data (3.2023.0218.1)
|
mime-types-data (3.2023.0218.1)
|
||||||
mini_magick (4.12.0)
|
mini_magick (4.12.0)
|
||||||
mini_mime (1.1.5)
|
mini_mime (1.1.5)
|
||||||
mini_portile2 (2.8.8)
|
mini_portile2 (2.8.9)
|
||||||
minitest (5.25.5)
|
minitest (5.25.5)
|
||||||
mock_redis (0.36.0)
|
mock_redis (0.36.0)
|
||||||
ruby2_keywords
|
ruby2_keywords
|
||||||
@@ -502,14 +509,14 @@ GEM
|
|||||||
newrelic_rpm (9.6.0)
|
newrelic_rpm (9.6.0)
|
||||||
base64
|
base64
|
||||||
nio4r (2.7.3)
|
nio4r (2.7.3)
|
||||||
nokogiri (1.18.8)
|
nokogiri (1.18.9)
|
||||||
mini_portile2 (~> 2.8.2)
|
mini_portile2 (~> 2.8.2)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-arm64-darwin)
|
nokogiri (1.18.9-arm64-darwin)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-x86_64-darwin)
|
nokogiri (1.18.9-x86_64-darwin)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-x86_64-linux-gnu)
|
nokogiri (1.18.9-x86_64-linux-gnu)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
oauth (1.1.0)
|
oauth (1.1.0)
|
||||||
oauth-tty (~> 1.0, >= 1.0.1)
|
oauth-tty (~> 1.0, >= 1.0.1)
|
||||||
@@ -563,7 +570,7 @@ GEM
|
|||||||
method_source (~> 1.0)
|
method_source (~> 1.0)
|
||||||
pry-rails (0.3.9)
|
pry-rails (0.3.9)
|
||||||
pry (>= 0.10.4)
|
pry (>= 0.10.4)
|
||||||
public_suffix (6.0.0)
|
public_suffix (6.0.2)
|
||||||
puma (6.4.3)
|
puma (6.4.3)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
pundit (2.3.0)
|
pundit (2.3.0)
|
||||||
@@ -713,6 +720,15 @@ GEM
|
|||||||
ruby2ruby (2.5.0)
|
ruby2ruby (2.5.0)
|
||||||
ruby_parser (~> 3.1)
|
ruby_parser (~> 3.1)
|
||||||
sexp_processor (~> 4.6)
|
sexp_processor (~> 4.6)
|
||||||
|
ruby_llm (1.3.1)
|
||||||
|
base64
|
||||||
|
event_stream_parser (~> 1)
|
||||||
|
faraday (>= 1.10.0)
|
||||||
|
faraday-multipart (>= 1)
|
||||||
|
faraday-net_http (>= 1)
|
||||||
|
faraday-retry (>= 1)
|
||||||
|
marcel (~> 1.0)
|
||||||
|
zeitwerk (~> 2)
|
||||||
ruby_parser (3.20.0)
|
ruby_parser (3.20.0)
|
||||||
sexp_processor (~> 4.16)
|
sexp_processor (~> 4.16)
|
||||||
sass (3.7.4)
|
sass (3.7.4)
|
||||||
@@ -770,6 +786,9 @@ GEM
|
|||||||
fugit (~> 1.8)
|
fugit (~> 1.8)
|
||||||
globalid (>= 1.0.1)
|
globalid (>= 1.0.1)
|
||||||
sidekiq (>= 6)
|
sidekiq (>= 6)
|
||||||
|
sidekiq_alive (2.5.0)
|
||||||
|
gserver (~> 0.0.1)
|
||||||
|
sidekiq (>= 5, < 9)
|
||||||
signet (0.17.0)
|
signet (0.17.0)
|
||||||
addressable (~> 2.8)
|
addressable (~> 2.8)
|
||||||
faraday (>= 0.17.5, < 3.a)
|
faraday (>= 0.17.5, < 3.a)
|
||||||
@@ -808,7 +827,7 @@ GEM
|
|||||||
stripe (8.5.0)
|
stripe (8.5.0)
|
||||||
telephone_number (1.4.20)
|
telephone_number (1.4.20)
|
||||||
test-prof (1.2.1)
|
test-prof (1.2.1)
|
||||||
thor (1.3.1)
|
thor (1.4.0)
|
||||||
tilt (2.3.0)
|
tilt (2.3.0)
|
||||||
time_diff (0.3.0)
|
time_diff (0.3.0)
|
||||||
activesupport
|
activesupport
|
||||||
@@ -891,6 +910,7 @@ DEPENDENCIES
|
|||||||
administrate (>= 0.20.1)
|
administrate (>= 0.20.1)
|
||||||
administrate-field-active_storage (>= 1.0.3)
|
administrate-field-active_storage (>= 1.0.3)
|
||||||
administrate-field-belongs_to_search (>= 0.9.0)
|
administrate-field-belongs_to_search (>= 0.9.0)
|
||||||
|
ai-agents (>= 0.2.1)
|
||||||
annotate
|
annotate
|
||||||
attr_extras
|
attr_extras
|
||||||
audited (~> 5.4, >= 5.4.1)
|
audited (~> 5.4, >= 5.4.1)
|
||||||
@@ -994,6 +1014,7 @@ DEPENDENCIES
|
|||||||
shoulda-matchers
|
shoulda-matchers
|
||||||
sidekiq (>= 7.3.1)
|
sidekiq (>= 7.3.1)
|
||||||
sidekiq-cron (>= 1.12.0)
|
sidekiq-cron (>= 1.12.0)
|
||||||
|
sidekiq_alive
|
||||||
simplecov (= 0.17.1)
|
simplecov (= 0.17.1)
|
||||||
slack-ruby-client (~> 2.5.2)
|
slack-ruby-client (~> 2.5.2)
|
||||||
spring
|
spring
|
||||||
|
|||||||
@@ -41,8 +41,15 @@ run:
|
|||||||
|
|
||||||
force_run:
|
force_run:
|
||||||
rm -f ./.overmind.sock
|
rm -f ./.overmind.sock
|
||||||
|
rm -f tmp/pids/*.pid
|
||||||
overmind start -f Procfile.dev
|
overmind start -f Procfile.dev
|
||||||
|
|
||||||
|
force_run_tunnel:
|
||||||
|
lsof -ti:3000 | xargs kill -9 2>/dev/null || true
|
||||||
|
rm -f ./.overmind.sock
|
||||||
|
rm -f tmp/pids/*.pid
|
||||||
|
overmind start -f Procfile.tunnel
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
overmind connect backend
|
overmind connect backend
|
||||||
|
|
||||||
@@ -52,4 +59,4 @@ debug_worker:
|
|||||||
docker:
|
docker:
|
||||||
docker build -t $(APP_NAME) -f ./docker/Dockerfile .
|
docker build -t $(APP_NAME) -f ./docker/Dockerfile .
|
||||||
|
|
||||||
.PHONY: setup db_create db_migrate db_seed db_reset db console server burn docker run force_run debug debug_worker
|
.PHONY: setup db_create db_migrate db_seed db_reset db console server burn docker run force_run force_run_tunnel debug debug_worker
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
backend: DISABLE_MINI_PROFILER=true bin/rails s -p 3000
|
||||||
|
# https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695
|
||||||
|
worker: dotenv bundle exec sidekiq -C config/sidekiq.yml
|
||||||
|
vite: bin/vite build --watch
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
3.13.0
|
4.4.0
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
3.2.0
|
3.4.0
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
# We don't want to update the name of the identified original contact.
|
# We don't want to update the name of the identified original contact.
|
||||||
|
|
||||||
class ContactIdentifyAction
|
class ContactIdentifyAction
|
||||||
|
include UrlHelper
|
||||||
pattr_initialize [:contact!, :params!, { retain_original_contact_name: false, discard_invalid_attrs: false }]
|
pattr_initialize [:contact!, :params!, { retain_original_contact_name: false, discard_invalid_attrs: false }]
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
@@ -104,7 +105,14 @@ class ContactIdentifyAction
|
|||||||
# TODO: replace reject { |_k, v| v.blank? } with compact_blank when rails is upgraded
|
# TODO: replace reject { |_k, v| v.blank? } with compact_blank when rails is upgraded
|
||||||
@contact.discard_invalid_attrs if discard_invalid_attrs
|
@contact.discard_invalid_attrs if discard_invalid_attrs
|
||||||
@contact.save!
|
@contact.save!
|
||||||
Avatar::AvatarFromUrlJob.perform_later(@contact, params[:avatar_url]) if params[:avatar_url].present? && !@contact.avatar.attached?
|
enqueue_avatar_job
|
||||||
|
end
|
||||||
|
|
||||||
|
def enqueue_avatar_job
|
||||||
|
return unless params[:avatar_url].present? && !@contact.avatar.attached?
|
||||||
|
return unless url_valid?(params[:avatar_url])
|
||||||
|
|
||||||
|
Avatar::AvatarFromUrlJob.perform_later(@contact, params[:avatar_url])
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge_contact(base_contact, merge_contact)
|
def merge_contact(base_contact, merge_contact)
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ function toggleSecretField(e) {
|
|||||||
if (!textElement) return;
|
if (!textElement) return;
|
||||||
|
|
||||||
if (textElement.dataset.secretMasked === 'false') {
|
if (textElement.dataset.secretMasked === 'false') {
|
||||||
textElement.textContent = '•'.repeat(10);
|
const maskedLength = secretField.dataset.secretText?.length || 10;
|
||||||
|
textElement.textContent = '•'.repeat(maskedLength);
|
||||||
textElement.dataset.secretMasked = 'true';
|
textElement.dataset.secretMasked = 'true';
|
||||||
toggler.querySelector('svg use').setAttribute('xlink:href', '#eye-show');
|
toggler.querySelector('svg use').setAttribute('xlink:href', '#eye-show');
|
||||||
|
|
||||||
@@ -32,3 +33,13 @@ function copySecretField(e) {
|
|||||||
|
|
||||||
navigator.clipboard.writeText(secretField.dataset.secretText);
|
navigator.clipboard.writeText(secretField.dataset.secretText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
document.querySelectorAll('.cell-data__secret-field').forEach(field => {
|
||||||
|
const span = field.querySelector('[data-secret-masked]');
|
||||||
|
if (span && span.dataset.secretMasked === 'true') {
|
||||||
|
const len = field.dataset.secretText?.length || 10;
|
||||||
|
span.textContent = '•'.repeat(len);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -46,17 +46,25 @@
|
|||||||
|
|
||||||
.cell-data__secret-field {
|
.cell-data__secret-field {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
color: $hint-grey;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
flex: 1;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
[data-secret-toggler],
|
||||||
margin-left: 5px;
|
[data-secret-copier] {
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
color: inherit;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
fill: currentColor;
|
fill: currentColor;
|
||||||
|
height: 1.25rem;
|
||||||
|
width: 1.25rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
class V2::Reports::LabelSummaryBuilder < V2::Reports::BaseSummaryBuilder
|
||||||
|
attr_reader :account, :params
|
||||||
|
|
||||||
|
# rubocop:disable Lint/MissingSuper
|
||||||
|
# the parent class has no initialize
|
||||||
|
def initialize(account:, params:)
|
||||||
|
@account = account
|
||||||
|
@params = params
|
||||||
|
|
||||||
|
timezone_offset = (params[:timezone_offset] || 0).to_f
|
||||||
|
@timezone = ActiveSupport::TimeZone[timezone_offset]&.name
|
||||||
|
end
|
||||||
|
# rubocop:enable Lint/MissingSuper
|
||||||
|
|
||||||
|
def build
|
||||||
|
labels = account.labels.to_a
|
||||||
|
return [] if labels.empty?
|
||||||
|
|
||||||
|
report_data = collect_report_data
|
||||||
|
labels.map { |label| build_label_report(label, report_data) }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def collect_report_data
|
||||||
|
conversation_filter = build_conversation_filter
|
||||||
|
use_business_hours = use_business_hours?
|
||||||
|
|
||||||
|
{
|
||||||
|
conversation_counts: fetch_conversation_counts(conversation_filter),
|
||||||
|
resolved_counts: fetch_resolved_counts(conversation_filter),
|
||||||
|
resolution_metrics: fetch_metrics(conversation_filter, 'conversation_resolved', use_business_hours),
|
||||||
|
first_response_metrics: fetch_metrics(conversation_filter, 'first_response', use_business_hours),
|
||||||
|
reply_metrics: fetch_metrics(conversation_filter, 'reply_time', use_business_hours)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_label_report(label, report_data)
|
||||||
|
{
|
||||||
|
id: label.id,
|
||||||
|
name: label.title,
|
||||||
|
conversations_count: report_data[:conversation_counts][label.title] || 0,
|
||||||
|
avg_resolution_time: report_data[:resolution_metrics][label.title] || 0,
|
||||||
|
avg_first_response_time: report_data[:first_response_metrics][label.title] || 0,
|
||||||
|
avg_reply_time: report_data[:reply_metrics][label.title] || 0,
|
||||||
|
resolved_conversations_count: report_data[:resolved_counts][label.title] || 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def use_business_hours?
|
||||||
|
ActiveModel::Type::Boolean.new.cast(params[:business_hours])
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_conversation_filter
|
||||||
|
conversation_filter = { account_id: account.id }
|
||||||
|
conversation_filter[:created_at] = range if range.present?
|
||||||
|
|
||||||
|
conversation_filter
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_conversation_counts(conversation_filter)
|
||||||
|
fetch_counts(conversation_filter)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_resolved_counts(conversation_filter)
|
||||||
|
# since the base query is ActsAsTaggableOn,
|
||||||
|
# the status :resolved won't automatically be converted to integer status
|
||||||
|
fetch_counts(conversation_filter.merge(status: Conversation.statuses[:resolved]))
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_counts(conversation_filter)
|
||||||
|
ActsAsTaggableOn::Tagging
|
||||||
|
.joins('INNER JOIN conversations ON taggings.taggable_id = conversations.id')
|
||||||
|
.joins('INNER JOIN tags ON taggings.tag_id = tags.id')
|
||||||
|
.where(
|
||||||
|
taggable_type: 'Conversation',
|
||||||
|
context: 'labels',
|
||||||
|
conversations: conversation_filter
|
||||||
|
)
|
||||||
|
.select('tags.name, COUNT(taggings.*) AS count')
|
||||||
|
.group('tags.name')
|
||||||
|
.each_with_object({}) { |record, hash| hash[record.name] = record.count }
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_metrics(conversation_filter, event_name, use_business_hours)
|
||||||
|
ReportingEvent
|
||||||
|
.joins('INNER JOIN conversations ON reporting_events.conversation_id = conversations.id')
|
||||||
|
.joins('INNER JOIN taggings ON taggings.taggable_id = conversations.id')
|
||||||
|
.joins('INNER JOIN tags ON taggings.tag_id = tags.id')
|
||||||
|
.where(
|
||||||
|
conversations: conversation_filter,
|
||||||
|
name: event_name,
|
||||||
|
taggings: { taggable_type: 'Conversation', context: 'labels' }
|
||||||
|
)
|
||||||
|
.group('tags.name')
|
||||||
|
.order('tags.name')
|
||||||
|
.select(
|
||||||
|
'tags.name',
|
||||||
|
use_business_hours ? 'AVG(reporting_events.value_in_business_hours) as avg_value' : 'AVG(reporting_events.value) as avg_value'
|
||||||
|
)
|
||||||
|
.each_with_object({}) { |record, hash| hash[record.name] = record.avg_value.to_f }
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -29,6 +29,11 @@ class Api::V1::Accounts::AgentBotsController < Api::V1::Accounts::BaseController
|
|||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_access_token
|
||||||
|
@agent_bot.access_token.regenerate_token
|
||||||
|
@agent_bot.reload
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def agent_bot
|
def agent_bot
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Accounts::AgentCapacityPoliciesController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :ensure_enterprise_account
|
||||||
|
before_action :fetch_agent_capacity_policy, only: [:show, :update, :destroy, :set_inbox_limit, :remove_inbox_limit, :assign_user, :remove_user]
|
||||||
|
before_action :check_authorization
|
||||||
|
|
||||||
|
def index
|
||||||
|
@agent_capacity_policies = Enterprise::AgentCapacityPolicy.where(account_id: Current.account.id).includes(:users, :inbox_capacity_limits)
|
||||||
|
render json: { agent_capacity_policies: serialize_agent_capacity_policies(@agent_capacity_policies) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: { agent_capacity_policy: serialize_agent_capacity_policy(@agent_capacity_policy) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@agent_capacity_policy = Enterprise::AgentCapacityPolicy.new(agent_capacity_policy_params)
|
||||||
|
@agent_capacity_policy.account_id = Current.account.id
|
||||||
|
|
||||||
|
if @agent_capacity_policy.save
|
||||||
|
render json: { agent_capacity_policy: serialize_agent_capacity_policy(@agent_capacity_policy) }, status: :created
|
||||||
|
else
|
||||||
|
render json: { errors: @agent_capacity_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @agent_capacity_policy.update(agent_capacity_policy_params)
|
||||||
|
render json: { agent_capacity_policy: serialize_agent_capacity_policy(@agent_capacity_policy) }
|
||||||
|
else
|
||||||
|
render json: { errors: @agent_capacity_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @agent_capacity_policy.destroy
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render json: { errors: @agent_capacity_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set inbox capacity limit for a policy
|
||||||
|
def set_inbox_limit
|
||||||
|
inbox = Current.account.inboxes.find(params[:inbox_id])
|
||||||
|
inbox_limit = @agent_capacity_policy.inbox_capacity_limits.find_or_initialize_by(inbox: inbox)
|
||||||
|
|
||||||
|
if inbox_limit.update(conversation_limit: params[:conversation_limit])
|
||||||
|
render json: {
|
||||||
|
inbox_capacity_limit: serialize_inbox_capacity_limit(inbox_limit)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
render json: { errors: inbox_limit.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove inbox capacity limit from a policy
|
||||||
|
def remove_inbox_limit
|
||||||
|
inbox = Current.account.inboxes.find(params[:inbox_id])
|
||||||
|
inbox_limit = @agent_capacity_policy.inbox_capacity_limits.find_by(inbox: inbox)
|
||||||
|
|
||||||
|
if inbox_limit
|
||||||
|
if inbox_limit.destroy
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render json: { errors: inbox_limit.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render json: { error: 'Inbox limit not found' }, status: :not_found
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Assign a user to a capacity policy
|
||||||
|
def assign_user
|
||||||
|
user = Current.account.users.find(params[:user_id])
|
||||||
|
account_user = Current.account.account_users.find_by!(user: user)
|
||||||
|
|
||||||
|
# Update the account_user to assign to this policy
|
||||||
|
if account_user.update(agent_capacity_policy_id: @agent_capacity_policy.id)
|
||||||
|
render json: {
|
||||||
|
message: 'User assigned successfully',
|
||||||
|
user_id: user.id,
|
||||||
|
agent_capacity_policy_id: @agent_capacity_policy.id
|
||||||
|
}
|
||||||
|
else
|
||||||
|
render json: { errors: account_user.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove a user from a capacity policy
|
||||||
|
def remove_user
|
||||||
|
user = Current.account.users.find(params[:user_id])
|
||||||
|
account_user = Current.account.account_users.find_by!(user: user)
|
||||||
|
|
||||||
|
if account_user.agent_capacity_policy_id == @agent_capacity_policy.id
|
||||||
|
if account_user.update(agent_capacity_policy_id: nil)
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render json: { errors: account_user.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render json: { error: 'User not assigned to this policy' }, status: :not_found
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get current capacity status for an agent
|
||||||
|
def agent_capacity
|
||||||
|
user = Current.account.users.find(params[:agent_id])
|
||||||
|
inbox = params[:inbox_id] ? Current.account.inboxes.find(params[:inbox_id]) : nil
|
||||||
|
|
||||||
|
capacity_service = Enterprise::AssignmentV2::CapacityService.new
|
||||||
|
capacity_data = if inbox
|
||||||
|
capacity_service.get_agent_capacity(user, inbox)
|
||||||
|
else
|
||||||
|
capacity_service.get_agent_overall_capacity(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: { agent_capacity: capacity_data }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def ensure_enterprise_account
|
||||||
|
return if Current.account.feature_enabled?(:enterprise_agent_capacity)
|
||||||
|
|
||||||
|
render json: {
|
||||||
|
error: 'Agent capacity policies are only available for enterprise accounts'
|
||||||
|
}, status: :forbidden
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_agent_capacity_policy
|
||||||
|
@agent_capacity_policy = Enterprise::AgentCapacityPolicy
|
||||||
|
.where(account_id: Current.account.id)
|
||||||
|
.includes(:users, inbox_capacity_limits: :inbox)
|
||||||
|
.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def agent_capacity_policy_params
|
||||||
|
params.require(:agent_capacity_policy).permit(:name, :description, exclusion_rules: {})
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_authorization
|
||||||
|
authorize(Enterprise::AgentCapacityPolicy) if defined?(Enterprise::AgentCapacityPolicy)
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_agent_capacity_policy(policy)
|
||||||
|
{
|
||||||
|
id: policy.id,
|
||||||
|
name: policy.name,
|
||||||
|
description: policy.description,
|
||||||
|
exclusion_rules: policy.exclusion_rules,
|
||||||
|
user_count: policy.users.count,
|
||||||
|
inbox_limit_count: policy.inbox_capacity_limits.count,
|
||||||
|
inbox_limits: policy.inbox_capacity_limits.map { |limit| serialize_inbox_capacity_limit(limit) },
|
||||||
|
users: policy.users.map { |user| { id: user.id, name: user.name, email: user.email, avatar_url: user.avatar_url } },
|
||||||
|
created_at: policy.created_at,
|
||||||
|
updated_at: policy.updated_at
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_agent_capacity_policies(policies)
|
||||||
|
policies.map { |policy| serialize_agent_capacity_policy(policy) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_inbox_capacity_limit(limit)
|
||||||
|
{
|
||||||
|
id: limit.id,
|
||||||
|
inbox_id: limit.inbox_id,
|
||||||
|
inbox_name: limit.inbox.name,
|
||||||
|
conversation_limit: limit.conversation_limit,
|
||||||
|
created_at: limit.created_at,
|
||||||
|
updated_at: limit.updated_at
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Accounts::AssignmentPoliciesController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :fetch_assignment_policy, only: [:show, :update, :destroy]
|
||||||
|
before_action :check_authorization
|
||||||
|
|
||||||
|
def index
|
||||||
|
@assignment_policies = Current.account.assignment_policies.includes(:inboxes)
|
||||||
|
render json: { assignment_policies: serialize_assignment_policies(@assignment_policies) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: { assignment_policy: serialize_assignment_policy(@assignment_policy) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@assignment_policy = Current.account.assignment_policies.build(assignment_policy_params)
|
||||||
|
|
||||||
|
if @assignment_policy.save
|
||||||
|
render json: { assignment_policy: serialize_assignment_policy(@assignment_policy) }, status: :created
|
||||||
|
else
|
||||||
|
render json: { errors: @assignment_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @assignment_policy.update(assignment_policy_params)
|
||||||
|
render json: { assignment_policy: serialize_assignment_policy(@assignment_policy) }
|
||||||
|
else
|
||||||
|
render json: { errors: @assignment_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @assignment_policy.destroy
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render json: { errors: @assignment_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def fetch_assignment_policy
|
||||||
|
@assignment_policy = Current.account.assignment_policies.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def assignment_policy_params
|
||||||
|
params.require(:assignment_policy).permit(
|
||||||
|
:name, :description, :assignment_order, :conversation_priority,
|
||||||
|
:fair_distribution_limit, :fair_distribution_window, :enabled
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_assignment_policy(policy)
|
||||||
|
{
|
||||||
|
id: policy.id,
|
||||||
|
name: policy.name,
|
||||||
|
description: policy.description,
|
||||||
|
assignment_order: policy.assignment_order,
|
||||||
|
conversation_priority: policy.conversation_priority,
|
||||||
|
fair_distribution_limit: policy.fair_distribution_limit,
|
||||||
|
fair_distribution_window: policy.fair_distribution_window,
|
||||||
|
enabled: policy.enabled,
|
||||||
|
inbox_count: policy.inboxes.count,
|
||||||
|
inboxes: policy.inboxes.map { |inbox| { id: inbox.id, name: inbox.name } },
|
||||||
|
created_at: policy.created_at,
|
||||||
|
updated_at: policy.updated_at
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_assignment_policies(policies)
|
||||||
|
policies.map { |policy| serialize_assignment_policy(policy) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_authorization
|
||||||
|
authorize(AssignmentPolicy)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -30,7 +30,14 @@ class Api::V1::Accounts::CallbacksController < Api::V1::Accounts::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def facebook_pages
|
def facebook_pages
|
||||||
@page_details = mark_already_existing_facebook_pages(fb_object.get_connections('me', 'accounts'))
|
pages = []
|
||||||
|
fb_pages = fb_object.get_connections('me', 'accounts')
|
||||||
|
pages.concat(fb_pages)
|
||||||
|
while fb_pages.respond_to?(:next_page) && (next_page = fb_pages.next_page)
|
||||||
|
fb_pages = next_page
|
||||||
|
pages.concat(fb_pages)
|
||||||
|
end
|
||||||
|
@page_details = mark_already_existing_facebook_pages(pages)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_instagram_id(page_access_token, facebook_channel)
|
def set_instagram_id(page_access_token, facebook_channel)
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ class Api::V1::Accounts::CampaignsController < Api::V1::Accounts::BaseController
|
|||||||
|
|
||||||
def campaign_params
|
def campaign_params
|
||||||
params.require(:campaign).permit(:title, :description, :message, :enabled, :trigger_only_during_business_hours, :inbox_id, :sender_id,
|
params.require(:campaign).permit(:title, :description, :message, :enabled, :trigger_only_during_business_hours, :inbox_id, :sender_id,
|
||||||
:scheduled_at, audience: [:type, :id], trigger_rules: {})
|
:scheduled_at, audience: [:type, :id], trigger_rules: {}, template_params: {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
|||||||
before_action :check_authorization
|
before_action :check_authorization
|
||||||
before_action :set_current_page, only: [:index, :active, :search, :filter]
|
before_action :set_current_page, only: [:index, :active, :search, :filter]
|
||||||
before_action :fetch_contact, only: [:show, :update, :destroy, :avatar, :contactable_inboxes, :destroy_custom_attributes]
|
before_action :fetch_contact, only: [:show, :update, :destroy, :avatar, :contactable_inboxes, :destroy_custom_attributes]
|
||||||
before_action :set_include_contact_inboxes, only: [:index, :search, :filter, :show, :update]
|
before_action :set_include_contact_inboxes, only: [:index, :active, :search, :filter, :show, :update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@contacts_count = resolved_contacts.count
|
@contacts_count = resolved_contacts.count
|
||||||
@@ -56,7 +56,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
|||||||
contacts = Current.account.contacts.where(id: ::OnlineStatusTracker
|
contacts = Current.account.contacts.where(id: ::OnlineStatusTracker
|
||||||
.get_available_contact_ids(Current.account.id))
|
.get_available_contact_ids(Current.account.id))
|
||||||
@contacts_count = contacts.count
|
@contacts_count = contacts.count
|
||||||
@contacts = contacts.page(@current_page)
|
@contacts = fetch_contacts(contacts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show; end
|
||||||
@@ -122,7 +122,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
|||||||
def resolved_contacts
|
def resolved_contacts
|
||||||
return @resolved_contacts if @resolved_contacts
|
return @resolved_contacts if @resolved_contacts
|
||||||
|
|
||||||
@resolved_contacts = Current.account.contacts.resolved_contacts
|
@resolved_contacts = Current.account.contacts.resolved_contacts(use_crm_v2: Current.account.feature_enabled?('crm_v2'))
|
||||||
|
|
||||||
@resolved_contacts = @resolved_contacts.tagged_with(params[:labels], any: true) if params[:labels].present?
|
@resolved_contacts = @resolved_contacts.tagged_with(params[:labels], any: true) if params[:labels].present?
|
||||||
@resolved_contacts
|
@resolved_contacts
|
||||||
|
|||||||
@@ -124,6 +124,12 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
|||||||
@conversation.save!
|
@conversation.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
authorize @conversation, :destroy?
|
||||||
|
::DeleteObjectJob.perform_later(@conversation, Current.user, request.ip)
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def permitted_update_params
|
def permitted_update_params
|
||||||
|
|||||||
@@ -1,32 +1,23 @@
|
|||||||
class Api::V1::Accounts::Google::AuthorizationsController < Api::V1::Accounts::BaseController
|
class Api::V1::Accounts::Google::AuthorizationsController < Api::V1::Accounts::OauthAuthorizationController
|
||||||
include GoogleConcern
|
include GoogleConcern
|
||||||
before_action :check_authorization
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
email = params[:authorization][:email]
|
|
||||||
redirect_url = google_client.auth_code.authorize_url(
|
redirect_url = google_client.auth_code.authorize_url(
|
||||||
{
|
{
|
||||||
redirect_uri: "#{base_url}/google/callback",
|
redirect_uri: "#{base_url}/google/callback",
|
||||||
scope: 'email profile https://mail.google.com/',
|
scope: scope,
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
prompt: 'consent', # the oauth flow does not return a refresh token, this is supposed to fix it
|
prompt: 'consent', # the oauth flow does not return a refresh token, this is supposed to fix it
|
||||||
access_type: 'offline', # the default is 'online'
|
access_type: 'offline', # the default is 'online'
|
||||||
|
state: state,
|
||||||
client_id: GlobalConfigService.load('GOOGLE_OAUTH_CLIENT_ID', nil)
|
client_id: GlobalConfigService.load('GOOGLE_OAUTH_CLIENT_ID', nil)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if redirect_url
|
if redirect_url
|
||||||
cache_key = "google::#{email.downcase}"
|
|
||||||
::Redis::Alfred.setex(cache_key, Current.account.id, 5.minutes)
|
|
||||||
render json: { success: true, url: redirect_url }
|
render json: { success: true, url: redirect_url }
|
||||||
else
|
else
|
||||||
render json: { success: false }, status: :unprocessable_entity
|
render json: { success: false }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def check_authorization
|
|
||||||
raise Pundit::NotAuthorizedError unless Current.account_user.administrator?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Accounts::InboxAssignmentPoliciesController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :fetch_inbox
|
||||||
|
before_action :check_authorization
|
||||||
|
|
||||||
|
def show
|
||||||
|
@inbox_assignment_policy = @inbox.inbox_assignment_policy
|
||||||
|
|
||||||
|
if @inbox_assignment_policy
|
||||||
|
render json: {
|
||||||
|
inbox_assignment_policy: serialize_inbox_assignment_policy(@inbox_assignment_policy)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
render json: {
|
||||||
|
inbox_assignment_policy: nil,
|
||||||
|
message: 'No assignment policy assigned to this inbox'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
# Remove existing assignment if any
|
||||||
|
@inbox.inbox_assignment_policy&.destroy
|
||||||
|
|
||||||
|
@assignment_policy = Current.account.assignment_policies.find(params[:assignment_policy_id])
|
||||||
|
@inbox_assignment_policy = @inbox.build_inbox_assignment_policy(assignment_policy: @assignment_policy)
|
||||||
|
|
||||||
|
if @inbox_assignment_policy.save
|
||||||
|
render json: {
|
||||||
|
inbox_assignment_policy: serialize_inbox_assignment_policy(@inbox_assignment_policy)
|
||||||
|
}, status: :created
|
||||||
|
else
|
||||||
|
render json: { errors: @inbox_assignment_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@inbox_assignment_policy = @inbox.inbox_assignment_policy
|
||||||
|
|
||||||
|
if @inbox_assignment_policy
|
||||||
|
if @inbox_assignment_policy.destroy
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render json: { errors: @inbox_assignment_policy.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render json: { error: 'No assignment policy found for this inbox' }, status: :not_found
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def fetch_inbox
|
||||||
|
@inbox = Current.account.inboxes.find(params[:inbox_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_authorization
|
||||||
|
authorize(@inbox, :update?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_inbox_assignment_policy(inbox_assignment_policy)
|
||||||
|
{
|
||||||
|
id: inbox_assignment_policy.id,
|
||||||
|
inbox_id: inbox_assignment_policy.inbox_id,
|
||||||
|
assignment_policy_id: inbox_assignment_policy.assignment_policy_id,
|
||||||
|
assignment_policy: {
|
||||||
|
id: inbox_assignment_policy.assignment_policy.id,
|
||||||
|
name: inbox_assignment_policy.assignment_policy.name,
|
||||||
|
description: inbox_assignment_policy.assignment_policy.description,
|
||||||
|
assignment_order: inbox_assignment_policy.assignment_policy.assignment_order,
|
||||||
|
conversation_priority: inbox_assignment_policy.assignment_policy.conversation_priority,
|
||||||
|
fair_distribution_limit: inbox_assignment_policy.assignment_policy.fair_distribution_limit,
|
||||||
|
fair_distribution_window: inbox_assignment_policy.assignment_policy.fair_distribution_window,
|
||||||
|
enabled: inbox_assignment_policy.assignment_policy.enabled
|
||||||
|
},
|
||||||
|
created_at: inbox_assignment_policy.created_at,
|
||||||
|
updated_at: inbox_assignment_policy.updated_at
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -69,6 +69,17 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
|||||||
render status: :ok, json: { message: I18n.t('messages.inbox_deletetion_response') }
|
render status: :ok, json: { message: I18n.t('messages.inbox_deletetion_response') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sync_templates
|
||||||
|
unless @inbox.channel.is_a?(Channel::Whatsapp)
|
||||||
|
return render status: :unprocessable_entity, json: { error: 'Template sync is only available for WhatsApp channels' }
|
||||||
|
end
|
||||||
|
|
||||||
|
Channels::Whatsapp::TemplatesSyncJob.perform_later(@inbox.channel)
|
||||||
|
render status: :ok, json: { message: 'Template sync initiated successfully' }
|
||||||
|
rescue StandardError => e
|
||||||
|
render status: :internal_server_error, json: { error: e.message }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def fetch_inbox
|
def fetch_inbox
|
||||||
@@ -81,11 +92,15 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_channel
|
def create_channel
|
||||||
return unless %w[web_widget api email line telegram whatsapp sms].include?(permitted_params[:channel][:type])
|
return unless allowed_channel_types.include?(permitted_params[:channel][:type])
|
||||||
|
|
||||||
account_channels_method.create!(permitted_params(channel_type_from_params::EDITABLE_ATTRS)[:channel].except(:type))
|
account_channels_method.create!(permitted_params(channel_type_from_params::EDITABLE_ATTRS)[:channel].except(:type))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allowed_channel_types
|
||||||
|
%w[web_widget api email line telegram whatsapp sms]
|
||||||
|
end
|
||||||
|
|
||||||
def update_inbox_working_hours
|
def update_inbox_working_hours
|
||||||
@inbox.update_working_hours(params.permit(working_hours: Inbox::OFFISABLE_ATTRS)[:working_hours]) if params[:working_hours]
|
@inbox.update_working_hours(params.permit(working_hours: Inbox::OFFISABLE_ATTRS)[:working_hours]) if params[:working_hours]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
class Api::V1::Accounts::Instagram::AuthorizationsController < Api::V1::Accounts::BaseController
|
class Api::V1::Accounts::Instagram::AuthorizationsController < Api::V1::Accounts::OauthAuthorizationController
|
||||||
include InstagramConcern
|
include InstagramConcern
|
||||||
include Instagram::IntegrationHelper
|
include Instagram::IntegrationHelper
|
||||||
before_action :check_authorization
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login/business-login#step-1--get-authorization
|
# https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login/business-login#step-1--get-authorization
|
||||||
@@ -21,10 +20,4 @@ class Api::V1::Accounts::Instagram::AuthorizationsController < Api::V1::Accounts
|
|||||||
render json: { success: false }, status: :unprocessable_entity
|
render json: { success: false }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def check_authorization
|
|
||||||
raise Pundit::NotAuthorizedError unless Current.account_user.administrator?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::BaseController
|
class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::BaseController
|
||||||
before_action :fetch_conversation, only: [:link_issue, :linked_issues]
|
before_action :fetch_conversation, only: [:create_issue, :link_issue, :unlink_issue, :linked_issues]
|
||||||
before_action :fetch_hook, only: [:destroy]
|
before_action :fetch_hook, only: [:destroy]
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
revoke_linear_token
|
||||||
@hook.destroy!
|
@hook.destroy!
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
@@ -27,10 +28,16 @@ class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::Bas
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_issue
|
def create_issue
|
||||||
issue = linear_processor_service.create_issue(permitted_params)
|
issue = linear_processor_service.create_issue(permitted_params, Current.user)
|
||||||
if issue[:error]
|
if issue[:error]
|
||||||
render json: { error: issue[:error] }, status: :unprocessable_entity
|
render json: { error: issue[:error] }, status: :unprocessable_entity
|
||||||
else
|
else
|
||||||
|
Linear::ActivityMessageService.new(
|
||||||
|
conversation: @conversation,
|
||||||
|
action_type: :issue_created,
|
||||||
|
issue_data: { id: issue[:data][:identifier] },
|
||||||
|
user: Current.user
|
||||||
|
).perform
|
||||||
render json: issue[:data], status: :ok
|
render json: issue[:data], status: :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -38,21 +45,34 @@ class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::Bas
|
|||||||
def link_issue
|
def link_issue
|
||||||
issue_id = permitted_params[:issue_id]
|
issue_id = permitted_params[:issue_id]
|
||||||
title = permitted_params[:title]
|
title = permitted_params[:title]
|
||||||
issue = linear_processor_service.link_issue(conversation_link, issue_id, title)
|
issue = linear_processor_service.link_issue(conversation_link, issue_id, title, Current.user)
|
||||||
if issue[:error]
|
if issue[:error]
|
||||||
render json: { error: issue[:error] }, status: :unprocessable_entity
|
render json: { error: issue[:error] }, status: :unprocessable_entity
|
||||||
else
|
else
|
||||||
|
Linear::ActivityMessageService.new(
|
||||||
|
conversation: @conversation,
|
||||||
|
action_type: :issue_linked,
|
||||||
|
issue_data: { id: issue_id },
|
||||||
|
user: Current.user
|
||||||
|
).perform
|
||||||
render json: issue[:data], status: :ok
|
render json: issue[:data], status: :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink_issue
|
def unlink_issue
|
||||||
link_id = permitted_params[:link_id]
|
link_id = permitted_params[:link_id]
|
||||||
|
issue_id = permitted_params[:issue_id]
|
||||||
issue = linear_processor_service.unlink_issue(link_id)
|
issue = linear_processor_service.unlink_issue(link_id)
|
||||||
|
|
||||||
if issue[:error]
|
if issue[:error]
|
||||||
render json: { error: issue[:error] }, status: :unprocessable_entity
|
render json: { error: issue[:error] }, status: :unprocessable_entity
|
||||||
else
|
else
|
||||||
|
Linear::ActivityMessageService.new(
|
||||||
|
conversation: @conversation,
|
||||||
|
action_type: :issue_unlinked,
|
||||||
|
issue_data: { id: issue_id },
|
||||||
|
user: Current.user
|
||||||
|
).perform
|
||||||
render json: issue[:data], status: :ok
|
render json: issue[:data], status: :ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -101,4 +121,15 @@ class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::Bas
|
|||||||
def fetch_hook
|
def fetch_hook
|
||||||
@hook = Integrations::Hook.where(account: Current.account).find_by(app_id: 'linear')
|
@hook = Integrations::Hook.where(account: Current.account).find_by(app_id: 'linear')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revoke_linear_token
|
||||||
|
return unless @hook&.access_token
|
||||||
|
|
||||||
|
begin
|
||||||
|
linear_client = Linear.new(@hook.access_token)
|
||||||
|
linear_client.revoke_token
|
||||||
|
rescue StandardError => e
|
||||||
|
Rails.logger.error "Failed to revoke Linear token: #{e.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
class Api::V1::Accounts::Integrations::NotionController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :fetch_hook, only: [:destroy]
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@hook.destroy!
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def fetch_hook
|
||||||
|
@hook = Integrations::Hook.where(account: Current.account).find_by(app_id: 'notion')
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Accounts::LeavesController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :fetch_leave, only: [:show, :update, :destroy, :approve, :reject]
|
||||||
|
before_action -> { check_authorization(Leave) }, only: [:index, :create]
|
||||||
|
before_action :authorize_leave, only: [:show, :update, :destroy]
|
||||||
|
before_action :authorize_approval, only: [:approve, :reject]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@leaves = leave_service.list(filter_params)
|
||||||
|
render json: { leaves: serialize_leaves(@leaves) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: { leave: serialize_leave(@leave) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
account_user = find_or_authorize_account_user
|
||||||
|
service = Leaves::LeaveService.new(
|
||||||
|
account: Current.account,
|
||||||
|
account_user: account_user,
|
||||||
|
current_user: Current.user
|
||||||
|
)
|
||||||
|
|
||||||
|
result = service.create(leave_params)
|
||||||
|
|
||||||
|
if result[:success]
|
||||||
|
render json: { leave: serialize_leave(result[:leave]) }, status: :created
|
||||||
|
else
|
||||||
|
render json: { errors: result[:errors] }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
result = leave_service.update(@leave, leave_params)
|
||||||
|
|
||||||
|
if result[:success]
|
||||||
|
render json: { leave: serialize_leave(result[:leave]) }
|
||||||
|
else
|
||||||
|
render json: { errors: result[:errors] }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @leave.destroy
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
render json: { errors: @leave.errors.full_messages }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def approve
|
||||||
|
service = Leaves::LeaveApprovalService.new(leave: @leave, approver: Current.user)
|
||||||
|
result = service.approve(params[:comments])
|
||||||
|
|
||||||
|
if result[:success]
|
||||||
|
render json: { leave: serialize_leave(result[:leave]) }
|
||||||
|
else
|
||||||
|
render json: { errors: result[:errors] }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def reject
|
||||||
|
service = Leaves::LeaveApprovalService.new(leave: @leave, approver: Current.user)
|
||||||
|
result = service.reject(params[:reason])
|
||||||
|
|
||||||
|
if result[:success]
|
||||||
|
render json: { leave: serialize_leave(result[:leave]) }
|
||||||
|
else
|
||||||
|
render json: { errors: result[:errors] }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def fetch_leave
|
||||||
|
@leave = Current.account.leaves.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorize_leave
|
||||||
|
authorize @leave
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorize_approval
|
||||||
|
authorize @leave, :approve?
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_or_authorize_account_user
|
||||||
|
if params[:user_id].present? && Current.account_user.administrator?
|
||||||
|
user = Current.account.users.find(params[:user_id])
|
||||||
|
Current.account.account_users.find_by!(user: user)
|
||||||
|
else
|
||||||
|
Current.account.account_users.find_by!(user: Current.user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def leave_service
|
||||||
|
@leave_service ||= if @leave
|
||||||
|
Leaves::LeaveService.new(
|
||||||
|
account: Current.account,
|
||||||
|
account_user: @leave.account_user,
|
||||||
|
current_user: Current.user
|
||||||
|
)
|
||||||
|
else
|
||||||
|
# For index action, we don't have a specific leave
|
||||||
|
Leaves::LeaveService.new(
|
||||||
|
account: Current.account,
|
||||||
|
account_user: nil,
|
||||||
|
current_user: Current.user
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def leave_params
|
||||||
|
params.require(:leave).permit(:start_date, :end_date, :leave_type, :reason)
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_params
|
||||||
|
params.permit(:status, :leave_type, :start_date, :end_date, :user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_leave(leave)
|
||||||
|
{
|
||||||
|
id: leave.id,
|
||||||
|
start_date: leave.start_date,
|
||||||
|
end_date: leave.end_date,
|
||||||
|
leave_type: leave.leave_type,
|
||||||
|
status: leave.status,
|
||||||
|
reason: leave.reason,
|
||||||
|
days_count: leave.days_count,
|
||||||
|
approved_by: leave.approved_by&.name,
|
||||||
|
approved_at: leave.approved_at,
|
||||||
|
user: {
|
||||||
|
id: leave.user.id,
|
||||||
|
name: leave.user.name,
|
||||||
|
email: leave.user.email,
|
||||||
|
avatar_url: leave.user.avatar_url
|
||||||
|
},
|
||||||
|
created_at: leave.created_at,
|
||||||
|
updated_at: leave.updated_at
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_leaves(leaves)
|
||||||
|
leaves.map { |leave| serialize_leave(leave) }
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,28 +1,19 @@
|
|||||||
class Api::V1::Accounts::Microsoft::AuthorizationsController < Api::V1::Accounts::BaseController
|
class Api::V1::Accounts::Microsoft::AuthorizationsController < Api::V1::Accounts::OauthAuthorizationController
|
||||||
include MicrosoftConcern
|
include MicrosoftConcern
|
||||||
before_action :check_authorization
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
email = params[:authorization][:email]
|
|
||||||
redirect_url = microsoft_client.auth_code.authorize_url(
|
redirect_url = microsoft_client.auth_code.authorize_url(
|
||||||
{
|
{
|
||||||
redirect_uri: "#{base_url}/microsoft/callback",
|
redirect_uri: "#{base_url}/microsoft/callback",
|
||||||
scope: 'offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send openid profile',
|
scope: scope,
|
||||||
|
state: state,
|
||||||
prompt: 'consent'
|
prompt: 'consent'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if redirect_url
|
if redirect_url
|
||||||
cache_key = "microsoft::#{email.downcase}"
|
|
||||||
::Redis::Alfred.setex(cache_key, Current.account.id, 5.minutes)
|
|
||||||
render json: { success: true, url: redirect_url }
|
render json: { success: true, url: redirect_url }
|
||||||
else
|
else
|
||||||
render json: { success: false }, status: :unprocessable_entity
|
render json: { success: false }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def check_authorization
|
|
||||||
raise Pundit::NotAuthorizedError unless Current.account_user.administrator?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
class Api::V1::Accounts::Notion::AuthorizationsController < Api::V1::Accounts::OauthAuthorizationController
|
||||||
|
include NotionConcern
|
||||||
|
|
||||||
|
def create
|
||||||
|
redirect_url = notion_client.auth_code.authorize_url(
|
||||||
|
{
|
||||||
|
redirect_uri: "#{base_url}/notion/callback",
|
||||||
|
response_type: 'code',
|
||||||
|
owner: 'user',
|
||||||
|
state: state,
|
||||||
|
client_id: GlobalConfigService.load('NOTION_CLIENT_ID', nil)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if redirect_url
|
||||||
|
render json: { success: true, url: redirect_url }
|
||||||
|
else
|
||||||
|
render json: { success: false }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
class Api::V1::Accounts::OauthAuthorizationController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :check_authorization
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def scope
|
||||||
|
''
|
||||||
|
end
|
||||||
|
|
||||||
|
def state
|
||||||
|
Current.account.to_sgid(expires_in: 15.minutes).to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def base_url
|
||||||
|
ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def check_authorization
|
||||||
|
raise Pundit::NotAuthorizedError unless Current.account_user.administrator?
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Accounts::Reports::AssignmentMetricsController < Api::V1::Accounts::BaseController
|
||||||
|
include AssignmentMetricsHelper
|
||||||
|
include DistributionMetrics
|
||||||
|
|
||||||
|
before_action :check_authorization
|
||||||
|
before_action :validate_date_range
|
||||||
|
|
||||||
|
def index
|
||||||
|
@metrics = metrics_service.compute_assignment_metrics
|
||||||
|
render json: { assignment_metrics: @metrics }
|
||||||
|
end
|
||||||
|
|
||||||
|
def agent_history
|
||||||
|
history_service = Reports::AgentHistoryService.new(Current.account, params)
|
||||||
|
|
||||||
|
if params[:agent_id].present?
|
||||||
|
@agent = Current.account.users.find(params[:agent_id])
|
||||||
|
@assignment_history = history_service.fetch_agent_assignment_history(@agent)
|
||||||
|
|
||||||
|
render json: {
|
||||||
|
agent: serialize_agent(@agent),
|
||||||
|
assignment_history: @assignment_history,
|
||||||
|
meta: pagination_meta
|
||||||
|
}
|
||||||
|
else
|
||||||
|
agents_summary = history_service.compute_all_agents_history
|
||||||
|
render json: { agents_history: agents_summary }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def policy_performance
|
||||||
|
@policies = Current.account.assignment_policies.includes(:inboxes)
|
||||||
|
performance_data = @policies.map do |policy|
|
||||||
|
metrics_service.compute_policy_performance(policy)
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: { policy_performance: performance_data }
|
||||||
|
end
|
||||||
|
|
||||||
|
def agent_utilization
|
||||||
|
agents = Current.account.users.joins(:account_users).where(account_users: { role: %w[agent administrator] })
|
||||||
|
utilization_data = agents.map do |agent|
|
||||||
|
metrics_service.compute_agent_utilization(agent)
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: { agent_utilization: utilization_data }
|
||||||
|
end
|
||||||
|
|
||||||
|
def assignment_distribution
|
||||||
|
distribution_data = {
|
||||||
|
by_inbox: metrics_service.compute_distribution_by_inbox,
|
||||||
|
by_team: metrics_service.compute_distribution_by_team,
|
||||||
|
by_hour: metrics_service.compute_distribution_by_hour,
|
||||||
|
by_day_of_week: compute_distribution_by_day_of_week
|
||||||
|
}
|
||||||
|
|
||||||
|
render json: { assignment_distribution: distribution_data }
|
||||||
|
end
|
||||||
|
|
||||||
|
def export
|
||||||
|
type = params[:type] || 'csv'
|
||||||
|
data = metrics_service.compute_assignment_metrics
|
||||||
|
|
||||||
|
case type
|
||||||
|
when 'csv'
|
||||||
|
export_service = Reports::AssignmentExportService.new(data)
|
||||||
|
send_data export_service.generate_csv, filename: "assignment_metrics_#{Date.current}.csv", type: 'text/csv'
|
||||||
|
when 'json'
|
||||||
|
send_data data.to_json, filename: "assignment_metrics_#{Date.current}.json", type: 'application/json'
|
||||||
|
else
|
||||||
|
render json: { error: 'Unsupported export type' }, status: :bad_request
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def validate_date_range
|
||||||
|
return if params[:since].blank? || params[:until].blank?
|
||||||
|
|
||||||
|
start_date = Date.parse(params[:since])
|
||||||
|
end_date = Date.parse(params[:until])
|
||||||
|
|
||||||
|
if start_date > end_date
|
||||||
|
render json: { error: 'Start date must be before end date' }, status: :unprocessable_entity
|
||||||
|
elsif (end_date - start_date).to_i > 365
|
||||||
|
render json: { error: 'Date range cannot exceed 365 days' }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
rescue Date::Error
|
||||||
|
render json: { error: 'Invalid date format' }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_authorization
|
||||||
|
authorize Current.account, :show_metrics?
|
||||||
|
end
|
||||||
|
|
||||||
|
def metrics_service
|
||||||
|
@metrics_service ||= Reports::AssignmentMetricsService.new(Current.account, params)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -15,6 +15,10 @@ class Api::V1::Accounts::SearchController < Api::V1::Accounts::BaseController
|
|||||||
@result = search('Message')
|
@result = search('Message')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def articles
|
||||||
|
@result = search('Article')
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def search(search_type)
|
def search(search_type)
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
class Api::V1::Accounts::Whatsapp::AuthorizationsController < Api::V1::Accounts::BaseController
|
||||||
|
before_action :validate_feature_enabled!
|
||||||
|
|
||||||
|
# POST /api/v1/accounts/:account_id/whatsapp/authorization
|
||||||
|
# Handles the embedded signup callback data from the Facebook SDK
|
||||||
|
def create
|
||||||
|
validate_embedded_signup_params!
|
||||||
|
channel = process_embedded_signup
|
||||||
|
render_success_response(channel.inbox)
|
||||||
|
rescue StandardError => e
|
||||||
|
render_error_response(e)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def process_embedded_signup
|
||||||
|
service = Whatsapp::EmbeddedSignupService.new(
|
||||||
|
account: Current.account,
|
||||||
|
code: params[:code],
|
||||||
|
business_id: params[:business_id],
|
||||||
|
waba_id: params[:waba_id],
|
||||||
|
phone_number_id: params[:phone_number_id]
|
||||||
|
)
|
||||||
|
service.perform
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_success_response(inbox)
|
||||||
|
render json: {
|
||||||
|
success: true,
|
||||||
|
id: inbox.id,
|
||||||
|
name: inbox.name,
|
||||||
|
channel_type: 'whatsapp'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_error_response(error)
|
||||||
|
Rails.logger.error "[WHATSAPP AUTHORIZATION] Embedded signup error: #{error.message}"
|
||||||
|
Rails.logger.error error.backtrace.join("\n")
|
||||||
|
render json: {
|
||||||
|
success: false,
|
||||||
|
error: error.message
|
||||||
|
}, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_feature_enabled!
|
||||||
|
return if Current.account.feature_whatsapp_embedded_signup?
|
||||||
|
|
||||||
|
render json: {
|
||||||
|
success: false,
|
||||||
|
error: 'WhatsApp embedded signup is not enabled for this account'
|
||||||
|
}, status: :forbidden
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_embedded_signup_params!
|
||||||
|
missing_params = []
|
||||||
|
missing_params << 'code' if params[:code].blank?
|
||||||
|
missing_params << 'business_id' if params[:business_id].blank?
|
||||||
|
missing_params << 'waba_id' if params[:waba_id].blank?
|
||||||
|
|
||||||
|
return if missing_params.empty?
|
||||||
|
|
||||||
|
raise ArgumentError, "Required parameters are missing: #{missing_params.join(', ')}"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -92,7 +92,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def settings_params
|
def settings_params
|
||||||
params.permit(:auto_resolve_after, :auto_resolve_message, :auto_resolve_ignore_waiting)
|
params.permit(:auto_resolve_after, :auto_resolve_message, :auto_resolve_ignore_waiting, :audio_transcriptions, :auto_resolve_label)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_signup_enabled
|
def check_signup_enabled
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ class Api::V1::ProfilesController < Api::BaseController
|
|||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_access_token
|
||||||
|
@user.access_token.regenerate_token
|
||||||
|
@user.reload
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_user
|
def set_user
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseController
|
class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseController
|
||||||
before_action :check_authorization
|
before_action :check_authorization
|
||||||
before_action :prepare_builder_params, only: [:agent, :team, :inbox]
|
before_action :prepare_builder_params, only: [:agent, :team, :inbox, :label]
|
||||||
|
|
||||||
def agent
|
def agent
|
||||||
render_report_with(V2::Reports::AgentSummaryBuilder)
|
render_report_with(V2::Reports::AgentSummaryBuilder)
|
||||||
@@ -14,6 +14,10 @@ class Api::V2::Accounts::SummaryReportsController < Api::V1::Accounts::BaseContr
|
|||||||
render_report_with(V2::Reports::InboxSummaryBuilder)
|
render_report_with(V2::Reports::InboxSummaryBuilder)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def label
|
||||||
|
render_report_with(V2::Reports::LabelSummaryBuilder)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_authorization
|
def check_authorization
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AssignmentMetricsHelper
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def compute_summary_metrics
|
||||||
|
conversations = filter_conversations_by_date_range
|
||||||
|
|
||||||
|
{
|
||||||
|
total_assignments: conversations.count,
|
||||||
|
average_assignment_time: calculate_average_assignment_time(conversations),
|
||||||
|
assignments_per_agent: calculate_assignments_per_agent(conversations),
|
||||||
|
unassigned_conversations: Current.account.conversations.open.unassigned.count,
|
||||||
|
policies_active: Current.account.assignment_policies.enabled.count
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_inbox_metrics
|
||||||
|
inboxes = params[:inbox_id].present? ? Current.account.inboxes.where(id: params[:inbox_id]) : Current.account.inboxes
|
||||||
|
|
||||||
|
inboxes.map do |inbox|
|
||||||
|
conversations = filter_conversations_by_date_range.where(inbox_id: inbox.id)
|
||||||
|
{
|
||||||
|
inbox_id: inbox.id,
|
||||||
|
inbox_name: inbox.name,
|
||||||
|
total_assignments: conversations.count,
|
||||||
|
average_assignment_time: calculate_average_assignment_time(conversations),
|
||||||
|
unique_agents: conversations.where.not(assignee_id: nil).distinct.count(:assignee_id),
|
||||||
|
assignment_policy: inbox.assignment_policy&.name
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_agent_metrics
|
||||||
|
agents = Current.account.users.joins(:account_users).where(account_users: { role: %w[agent administrator] })
|
||||||
|
|
||||||
|
agents.map do |agent|
|
||||||
|
conversations = filter_conversations_by_date_range.where(assignee_id: agent.id)
|
||||||
|
{
|
||||||
|
agent_id: agent.id,
|
||||||
|
agent_name: agent.name,
|
||||||
|
agent_email: agent.email,
|
||||||
|
assignment_count: conversations.count,
|
||||||
|
average_resolution_time: calculate_average_resolution_time(conversations),
|
||||||
|
current_load: agent.assigned_conversations.open.count,
|
||||||
|
capacity_utilization: compute_agent_capacity_utilization(agent)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_policy_metrics
|
||||||
|
Current.account.assignment_policies.enabled.map do |policy|
|
||||||
|
compute_policy_performance(policy)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_conversations_by_date_range
|
||||||
|
Current.account.conversations.where(created_at: date_range)
|
||||||
|
end
|
||||||
|
|
||||||
|
def date_range
|
||||||
|
@date_range ||= params[:since]..params[:until]
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_average_assignment_time(_conversations)
|
||||||
|
# Implementation
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_assignments_per_agent(conversations)
|
||||||
|
agents_count = conversations.where.not(assignee_id: nil).distinct.count(:assignee_id)
|
||||||
|
return 0 if agents_count.zero?
|
||||||
|
|
||||||
|
(conversations.count.to_f / agents_count).round(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_average_resolution_time(_conversations)
|
||||||
|
# Implementation
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_agent_capacity_utilization(_agent)
|
||||||
|
# Implementation
|
||||||
|
0.0
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_assignment_success_rate(_conversations)
|
||||||
|
# Implementation
|
||||||
|
100.0
|
||||||
|
end
|
||||||
|
|
||||||
|
def serialize_agent(agent)
|
||||||
|
{
|
||||||
|
id: agent.id,
|
||||||
|
name: agent.name,
|
||||||
|
email: agent.email
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def group_by_hour(conversations)
|
||||||
|
conversations.group_by_hour(:created_at).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def group_by_day(conversations)
|
||||||
|
conversations.group_by_day(:created_at).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def group_by_week(conversations)
|
||||||
|
conversations.group_by_week(:created_at).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def group_by_month(conversations)
|
||||||
|
conversations.group_by_month(:created_at).count
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module DistributionMetrics
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def compute_distribution_by_day_of_week
|
||||||
|
filter_conversations_by_date_range
|
||||||
|
.group_by_day_of_week(:created_at)
|
||||||
|
.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_policy_performance(policy)
|
||||||
|
inbox_ids = policy.inboxes.pluck(:id)
|
||||||
|
conversations = filter_conversations_by_date_range.where(inbox_id: inbox_ids)
|
||||||
|
|
||||||
|
{
|
||||||
|
policy_id: policy.id,
|
||||||
|
policy_name: policy.name,
|
||||||
|
assignment_order: policy.assignment_order,
|
||||||
|
total_assignments: conversations.count,
|
||||||
|
average_assignment_time: calculate_average_assignment_time(conversations),
|
||||||
|
success_rate: calculate_assignment_success_rate(conversations),
|
||||||
|
inbox_count: inbox_ids.count
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_agent_utilization(agent)
|
||||||
|
capacity_policy = agent.account_users.first&.agent_capacity_policy
|
||||||
|
assigned_conversations = agent.assigned_conversations.open.count
|
||||||
|
|
||||||
|
utilization = if capacity_policy
|
||||||
|
policy_limit = capacity_policy.inbox_capacity_limits.sum(:conversation_limit)
|
||||||
|
policy_limit.positive? ? (assigned_conversations.to_f / policy_limit * 100).round(2) : 0
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
{
|
||||||
|
agent: serialize_agent(agent),
|
||||||
|
assigned_conversations: assigned_conversations,
|
||||||
|
capacity_policy: capacity_policy&.name,
|
||||||
|
utilization_percentage: utilization,
|
||||||
|
available_capacity: capacity_policy ? capacity_policy.inbox_capacity_limits.sum(:conversation_limit) - assigned_conversations : nil
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_distribution_by_inbox
|
||||||
|
filter_conversations_by_date_range
|
||||||
|
.joins(:inbox)
|
||||||
|
.group('inboxes.id', 'inboxes.name')
|
||||||
|
.count
|
||||||
|
.map { |k, v| { inbox_id: k[0], inbox_name: k[1], count: v } }
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_distribution_by_team
|
||||||
|
filter_conversations_by_date_range
|
||||||
|
.joins(assignee: { team_members: :team })
|
||||||
|
.group('teams.id', 'teams.name')
|
||||||
|
.count
|
||||||
|
.map { |k, v| { team_id: k[0], team_name: k[1], count: v } }
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_distribution_by_hour
|
||||||
|
filter_conversations_by_date_range
|
||||||
|
.group_by_hour_of_day(:created_at)
|
||||||
|
.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_average_resolution_time(conversations)
|
||||||
|
resolved = conversations.resolved
|
||||||
|
return 0 if resolved.empty?
|
||||||
|
|
||||||
|
total_time = resolved.sum { |c| (c.last_activity_at - c.created_at) / 1.hour }
|
||||||
|
(total_time / resolved.count).round(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def calculate_assignment_success_rate(conversations)
|
||||||
|
total = conversations.count
|
||||||
|
return 0.0 if total.zero?
|
||||||
|
|
||||||
|
successful = conversations.where(status: %w[resolved snoozed]).count
|
||||||
|
(successful.to_f / total * 100).round(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pagination_meta
|
||||||
|
{
|
||||||
|
current_page: params[:page] || 1,
|
||||||
|
per_page: params[:per_page] || 50,
|
||||||
|
total_count: @assignment_history&.total_count || 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -14,7 +14,7 @@ module GoogleConcern
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def base_url
|
def scope
|
||||||
ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
|
'email profile https://mail.google.com/'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module MicrosoftConcern
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def base_url
|
def scope
|
||||||
ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
|
'offline_access https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send openid profile email'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
module NotionConcern
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def notion_client
|
||||||
|
app_id = GlobalConfigService.load('NOTION_CLIENT_ID', nil)
|
||||||
|
app_secret = GlobalConfigService.load('NOTION_CLIENT_SECRET', nil)
|
||||||
|
|
||||||
|
::OAuth2::Client.new(app_id, app_secret, {
|
||||||
|
site: 'https://api.notion.com',
|
||||||
|
authorize_url: 'https://api.notion.com/v1/oauth/authorize',
|
||||||
|
token_url: 'https://api.notion.com/v1/oauth/token',
|
||||||
|
auth_scheme: :basic_auth
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def scope
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -15,7 +15,7 @@ class DashboardController < ActionController::Base
|
|||||||
private
|
private
|
||||||
|
|
||||||
def ensure_html_format
|
def ensure_html_format
|
||||||
head :not_acceptable unless request.format.html?
|
render json: { error: 'Please use API routes instead of dashboard routes for JSON requests' }, status: :not_acceptable if request.format.json?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_global_config
|
def set_global_config
|
||||||
@@ -67,6 +67,8 @@ class DashboardController < ActionController::Base
|
|||||||
FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''),
|
FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''),
|
||||||
INSTAGRAM_APP_ID: GlobalConfigService.load('INSTAGRAM_APP_ID', ''),
|
INSTAGRAM_APP_ID: GlobalConfigService.load('INSTAGRAM_APP_ID', ''),
|
||||||
FACEBOOK_API_VERSION: GlobalConfigService.load('FACEBOOK_API_VERSION', 'v17.0'),
|
FACEBOOK_API_VERSION: GlobalConfigService.load('FACEBOOK_API_VERSION', 'v17.0'),
|
||||||
|
WHATSAPP_APP_ID: GlobalConfigService.load('WHATSAPP_APP_ID', ''),
|
||||||
|
WHATSAPP_CONFIGURATION_ID: GlobalConfigService.load('WHATSAPP_CONFIGURATION_ID', ''),
|
||||||
IS_ENTERPRISE: ChatwootApp.enterprise?,
|
IS_ENTERPRISE: ChatwootApp.enterprise?,
|
||||||
AZURE_APP_ID: GlobalConfigService.load('AZURE_APP_ID', ''),
|
AZURE_APP_ID: GlobalConfigService.load('AZURE_APP_ID', ''),
|
||||||
GIT_SHA: GIT_HASH
|
GIT_SHA: GIT_HASH
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class MicrosoftController < ApplicationController
|
|||||||
after_action :set_version_header
|
after_action :set_version_header
|
||||||
|
|
||||||
def identity_association
|
def identity_association
|
||||||
microsoft_indentity
|
microsoft_identity
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -11,7 +11,7 @@ class MicrosoftController < ApplicationController
|
|||||||
response.headers['Content-Length'] = { associatedApplications: [{ applicationId: @identity_json }] }.to_json.length
|
response.headers['Content-Length'] = { associatedApplications: [{ applicationId: @identity_json }] }.to_json.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def microsoft_indentity
|
def microsoft_identity
|
||||||
@identity_json = GlobalConfigService.load('AZURE_APP_ID', nil)
|
@identity_json = GlobalConfigService.load('AZURE_APP_ID', nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
class Notion::CallbacksController < OauthCallbackController
|
||||||
|
include NotionConcern
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def provider_name
|
||||||
|
'notion'
|
||||||
|
end
|
||||||
|
|
||||||
|
def oauth_client
|
||||||
|
notion_client
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_response
|
||||||
|
hook = account.hooks.new(
|
||||||
|
access_token: parsed_body['access_token'],
|
||||||
|
status: 'enabled',
|
||||||
|
app_id: 'notion',
|
||||||
|
settings: {
|
||||||
|
token_type: parsed_body['token_type'],
|
||||||
|
workspace_name: parsed_body['workspace_name'],
|
||||||
|
workspace_id: parsed_body['workspace_id'],
|
||||||
|
workspace_icon: parsed_body['workspace_icon'],
|
||||||
|
bot_id: parsed_body['bot_id'],
|
||||||
|
owner: parsed_body['owner']
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
hook.save!
|
||||||
|
redirect_to notion_redirect_uri
|
||||||
|
end
|
||||||
|
|
||||||
|
def notion_redirect_uri
|
||||||
|
"#{ENV.fetch('FRONTEND_URL', nil)}/app/accounts/#{account.id}/settings/integrations/notion"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -6,7 +6,6 @@ class OauthCallbackController < ApplicationController
|
|||||||
)
|
)
|
||||||
|
|
||||||
handle_response
|
handle_response
|
||||||
::Redis::Alfred.delete(cache_key)
|
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
ChatwootExceptionTracker.new(e).capture_exception
|
ChatwootExceptionTracker.new(e).capture_exception
|
||||||
redirect_to '/'
|
redirect_to '/'
|
||||||
@@ -64,13 +63,10 @@ class OauthCallbackController < ApplicationController
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_key
|
|
||||||
"#{provider_name}::#{users_data['email'].downcase}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_channel_with_inbox
|
def create_channel_with_inbox
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
channel_email = Channel::Email.create!(email: users_data['email'], account: account)
|
channel_email = Channel::Email.create!(email: users_data['email'], account: account)
|
||||||
|
|
||||||
account.inboxes.create!(
|
account.inboxes.create!(
|
||||||
account: account,
|
account: account,
|
||||||
channel: channel_email,
|
channel: channel_email,
|
||||||
@@ -85,12 +81,17 @@ class OauthCallbackController < ApplicationController
|
|||||||
decoded_token[0]
|
decoded_token[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_id
|
def account_from_signed_id
|
||||||
::Redis::Alfred.get(cache_key)
|
raise ActionController::BadRequest, 'Missing state variable' if params[:state].blank?
|
||||||
|
|
||||||
|
account = GlobalID::Locator.locate_signed(params[:state])
|
||||||
|
raise 'Invalid or expired state' if account.nil?
|
||||||
|
|
||||||
|
account
|
||||||
end
|
end
|
||||||
|
|
||||||
def account
|
def account
|
||||||
@account ||= Account.find(account_id)
|
@account ||= account_from_signed_id
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fallback name, for when name field is missing from users_data
|
# Fallback name, for when name field is missing from users_data
|
||||||
|
|||||||
@@ -1,19 +1,40 @@
|
|||||||
class Public::Api::V1::Portals::ArticlesController < Public::Api::V1::Portals::BaseController
|
class Public::Api::V1::Portals::ArticlesController < Public::Api::V1::Portals::BaseController
|
||||||
before_action :ensure_custom_domain_request, only: [:show, :index]
|
before_action :ensure_custom_domain_request, only: [:show, :index]
|
||||||
before_action :portal
|
before_action :portal
|
||||||
before_action :set_category, except: [:index, :show]
|
before_action :set_category, except: [:index, :show, :tracking_pixel]
|
||||||
before_action :set_article, only: [:show]
|
before_action :set_article, only: [:show]
|
||||||
layout 'portal'
|
layout 'portal'
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@articles = @portal.articles.published.includes(:category, :author)
|
@articles = @portal.articles.published.includes(:category, :author)
|
||||||
|
|
||||||
|
@articles = @articles.where(locale: permitted_params[:locale]) if permitted_params[:locale].present?
|
||||||
|
|
||||||
@articles_count = @articles.count
|
@articles_count = @articles.count
|
||||||
|
|
||||||
search_articles
|
search_articles
|
||||||
order_by_sort_param
|
order_by_sort_param
|
||||||
limit_results
|
limit_results
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@og_image_url = helpers.set_og_image_url(@portal.name, @article.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
def tracking_pixel
|
||||||
|
@article = @portal.articles.find_by(slug: permitted_params[:article_slug])
|
||||||
|
return head :not_found unless @article
|
||||||
|
|
||||||
|
@article.increment_view_count if @article.published?
|
||||||
|
|
||||||
|
# Serve the 1x1 tracking pixel with 24-hour private cache
|
||||||
|
# Private cache bypasses CDN but allows browser caching to prevent duplicate views from same user
|
||||||
|
expires_in 24.hours, public: false
|
||||||
|
response.headers['Content-Type'] = 'image/png'
|
||||||
|
|
||||||
|
pixel_path = Rails.public_path.join('assets/images/tracking-pixel.png')
|
||||||
|
send_file pixel_path, type: 'image/png', disposition: 'inline'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
@@ -39,7 +60,6 @@ class Public::Api::V1::Portals::ArticlesController < Public::Api::V1::Portals::B
|
|||||||
|
|
||||||
def set_article
|
def set_article
|
||||||
@article = @portal.articles.find_by(slug: permitted_params[:article_slug])
|
@article = @portal.articles.find_by(slug: permitted_params[:article_slug])
|
||||||
@article.increment_view_count if @article.published?
|
|
||||||
@parsed_content = render_article_content(@article.content)
|
@parsed_content = render_article_content(@article.content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ class Public::Api::V1::Portals::CategoriesController < Public::Api::V1::Portals:
|
|||||||
@categories = @portal.categories.order(position: :asc)
|
@categories = @portal.categories.order(position: :asc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@og_image_url = helpers.set_og_image_url(@portal.name, @category.name)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ class Public::Api::V1::PortalsController < Public::Api::V1::Portals::BaseControl
|
|||||||
before_action :redirect_to_portal_with_locale, only: [:show]
|
before_action :redirect_to_portal_with_locale, only: [:show]
|
||||||
layout 'portal'
|
layout 'portal'
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@og_image_url = helpers.set_og_image_url('', @portal.header_text)
|
||||||
|
end
|
||||||
|
|
||||||
def sitemap
|
def sitemap
|
||||||
@help_center_url = @portal.custom_domain || ChatwootApp.help_center_root
|
@help_center_url = @portal.custom_domain || ChatwootApp.help_center_root
|
||||||
|
|||||||
@@ -2,6 +2,13 @@ class SuperAdmin::AccountUsersController < SuperAdmin::ApplicationController
|
|||||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||||
# For example, you may want to send an email after a foo is updated.
|
# For example, you may want to send an email after a foo is updated.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Since account/user page - account user role attribute links to the show page
|
||||||
|
# Handle with a redirect to the user show page
|
||||||
|
def show
|
||||||
|
redirect_to super_admin_user_path(requested_resource.user)
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
resource = resource_class.new(resource_params)
|
resource = resource_class.new(resource_params)
|
||||||
authorize_resource(resource)
|
authorize_resource(resource)
|
||||||
|
|||||||
@@ -32,22 +32,20 @@ class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allowed_configs
|
def allowed_configs
|
||||||
@allowed_configs = case @config
|
mapping = {
|
||||||
when 'facebook'
|
'facebook' => %w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT],
|
||||||
%w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT]
|
'shopify' => %w[SHOPIFY_CLIENT_ID SHOPIFY_CLIENT_SECRET],
|
||||||
when 'shopify'
|
'microsoft' => %w[AZURE_APP_ID AZURE_APP_SECRET],
|
||||||
%w[SHOPIFY_CLIENT_ID SHOPIFY_CLIENT_SECRET]
|
'email' => ['MAILER_INBOUND_EMAIL_DOMAIN'],
|
||||||
when 'microsoft'
|
'linear' => %w[LINEAR_CLIENT_ID LINEAR_CLIENT_SECRET],
|
||||||
%w[AZURE_APP_ID AZURE_APP_SECRET]
|
'slack' => %w[SLACK_CLIENT_ID SLACK_CLIENT_SECRET],
|
||||||
when 'email'
|
'instagram' => %w[INSTAGRAM_APP_ID INSTAGRAM_APP_SECRET INSTAGRAM_VERIFY_TOKEN INSTAGRAM_API_VERSION ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT],
|
||||||
['MAILER_INBOUND_EMAIL_DOMAIN']
|
'whatsapp_embedded' => %w[WHATSAPP_APP_ID WHATSAPP_APP_SECRET WHATSAPP_CONFIGURATION_ID WHATSAPP_API_VERSION],
|
||||||
when 'linear'
|
'notion' => %w[NOTION_CLIENT_ID NOTION_CLIENT_SECRET],
|
||||||
%w[LINEAR_CLIENT_ID LINEAR_CLIENT_SECRET]
|
'google' => %w[GOOGLE_OAUTH_CLIENT_ID GOOGLE_OAUTH_CLIENT_SECRET GOOGLE_OAUTH_REDIRECT_URI]
|
||||||
when 'instagram'
|
}
|
||||||
%w[INSTAGRAM_APP_ID INSTAGRAM_APP_SECRET INSTAGRAM_VERIFY_TOKEN INSTAGRAM_API_VERSION ENABLE_INSTAGRAM_CHANNEL_HUMAN_AGENT]
|
|
||||||
else
|
@allowed_configs = mapping.fetch(@config, %w[ENABLE_ACCOUNT_SIGNUP FIREBASE_PROJECT_ID FIREBASE_CREDENTIALS])
|
||||||
%w[ENABLE_ACCOUNT_SIGNUP FIREBASE_PROJECT_ID FIREBASE_CREDENTIALS]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
class SuperAdmin::ApplicationController < Administrate::ApplicationController
|
class SuperAdmin::ApplicationController < Administrate::ApplicationController
|
||||||
include ActionView::Helpers::TagHelper
|
include ActionView::Helpers::TagHelper
|
||||||
include ActionView::Context
|
include ActionView::Context
|
||||||
|
include SuperAdmin::NavigationHelper
|
||||||
|
|
||||||
helper_method :render_vue_component
|
helper_method :render_vue_component, :settings_open?, :settings_pages
|
||||||
# authenticiation done via devise : SuperAdmin Model
|
# authenticiation done via devise : SuperAdmin Model
|
||||||
before_action :authenticate_super_admin!
|
before_action :authenticate_super_admin!
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ class Twilio::CallbackController < ApplicationController
|
|||||||
*Array.new(10) { |i| :"MediaUrl#{i}" },
|
*Array.new(10) { |i| :"MediaUrl#{i}" },
|
||||||
*Array.new(10) { |i| :"MediaContentType#{i}" },
|
*Array.new(10) { |i| :"MediaContentType#{i}" },
|
||||||
:MessagingServiceSid,
|
:MessagingServiceSid,
|
||||||
:NumMedia
|
:NumMedia,
|
||||||
|
:Latitude,
|
||||||
|
:Longitude,
|
||||||
|
:MessageType
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,16 @@ class Webhooks::InstagramController < ActionController::API
|
|||||||
def events
|
def events
|
||||||
Rails.logger.info('Instagram webhook received events')
|
Rails.logger.info('Instagram webhook received events')
|
||||||
if params['object'].casecmp('instagram').zero?
|
if params['object'].casecmp('instagram').zero?
|
||||||
::Webhooks::InstagramEventsJob.perform_later(params.to_unsafe_hash[:entry])
|
entry_params = params.to_unsafe_hash[:entry]
|
||||||
|
|
||||||
|
if contains_echo_event?(entry_params)
|
||||||
|
# Add delay to prevent race condition where echo arrives before send message API completes
|
||||||
|
# This avoids duplicate messages when echo comes early during API processing
|
||||||
|
::Webhooks::InstagramEventsJob.set(wait: 2.seconds).perform_later(entry_params)
|
||||||
|
else
|
||||||
|
::Webhooks::InstagramEventsJob.perform_later(entry_params)
|
||||||
|
end
|
||||||
|
|
||||||
render json: :ok
|
render json: :ok
|
||||||
else
|
else
|
||||||
Rails.logger.warn("Message is not received from the instagram webhook event: #{params['object']}")
|
Rails.logger.warn("Message is not received from the instagram webhook event: #{params['object']}")
|
||||||
@@ -14,6 +23,16 @@ class Webhooks::InstagramController < ActionController::API
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def contains_echo_event?(entry_params)
|
||||||
|
return false unless entry_params.is_a?(Array)
|
||||||
|
|
||||||
|
entry_params.any? do |entry|
|
||||||
|
# Check messaging array for echo events
|
||||||
|
messaging_events = entry[:messaging] || []
|
||||||
|
messaging_events.any? { |messaging| messaging.dig(:message, :is_echo).present? }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def valid_token?(token)
|
def valid_token?(token)
|
||||||
# Validates against both IG_VERIFY_TOKEN (Instagram channel via Facebook page) and
|
# Validates against both IG_VERIFY_TOKEN (Instagram channel via Facebook page) and
|
||||||
# INSTAGRAM_VERIFY_TOKEN (Instagram channel via direct Instagram login)
|
# INSTAGRAM_VERIFY_TOKEN (Instagram channel via direct Instagram login)
|
||||||
|
|||||||
@@ -36,9 +36,13 @@ module Api::V2::Accounts::ReportsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generate_labels_report
|
def generate_labels_report
|
||||||
Current.account.labels.map do |label|
|
reports = V2::Reports::LabelSummaryBuilder.new(
|
||||||
label_report = report_builder({ type: :label, id: label.id }).short_summary
|
account: Current.account,
|
||||||
[label.title] + generate_readable_report_metrics(label_report)
|
params: build_params({})
|
||||||
|
).build
|
||||||
|
|
||||||
|
reports.map do |report|
|
||||||
|
[report[:name]] + generate_readable_report_metrics(report)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
module MessageFormatHelper
|
module MessageFormatHelper
|
||||||
include RegexHelper
|
|
||||||
|
|
||||||
def transform_user_mention_content(message_content)
|
def transform_user_mention_content(message_content)
|
||||||
# attachment message without content, message_content is nil
|
# attachment message without content, message_content is nil
|
||||||
message_content.presence ? message_content.gsub(MENTION_REGEX, '\1') : ''
|
return '' unless message_content.presence
|
||||||
|
|
||||||
|
# Use CommonMarker to convert markdown to plain text for notifications
|
||||||
|
# This handles all markdown formatting (links, bold, italic, etc.) not just mentions
|
||||||
|
# Converts: [@👍 customer support](mention://team/1/%F0%9F%91%8D%20customer%20support)
|
||||||
|
# To: @👍 customer support
|
||||||
|
CommonMarker.render_doc(message_content).to_plaintext.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_message_content(message_content)
|
def render_message_content(message_content)
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
module PortalHelper
|
module PortalHelper
|
||||||
|
def set_og_image_url(portal_name, title)
|
||||||
|
cdn_url = GlobalConfig.get('OG_IMAGE_CDN_URL')['OG_IMAGE_CDN_URL']
|
||||||
|
return if cdn_url.blank?
|
||||||
|
|
||||||
|
client_ref = GlobalConfig.get('OG_IMAGE_CLIENT_REF')['OG_IMAGE_CLIENT_REF']
|
||||||
|
|
||||||
|
uri = URI.parse(cdn_url)
|
||||||
|
uri.path = '/og'
|
||||||
|
uri.query = URI.encode_www_form(
|
||||||
|
clientRef: client_ref,
|
||||||
|
title: title,
|
||||||
|
portalName: portal_name
|
||||||
|
)
|
||||||
|
|
||||||
|
uri.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def generate_portal_bg_color(portal_color, theme)
|
def generate_portal_bg_color(portal_color, theme)
|
||||||
base_color = theme == 'dark' ? 'black' : 'white'
|
base_color = theme == 'dark' ? 'black' : 'white'
|
||||||
"color-mix(in srgb, #{portal_color} 20%, #{base_color})"
|
"color-mix(in srgb, #{portal_color} 20%, #{base_color})"
|
||||||
|
|||||||
+51
-16
@@ -1,5 +1,7 @@
|
|||||||
# TODO: Move this values to features.yml itself
|
# TODO: Move this values to features.yml itself
|
||||||
# No need to replicate the same values in two places
|
# No need to replicate the same values in two places
|
||||||
|
|
||||||
|
# ------- Premium Features ------- #
|
||||||
captain:
|
captain:
|
||||||
name: 'Captain'
|
name: 'Captain'
|
||||||
description: 'Enable AI-powered conversations with your customers.'
|
description: 'Enable AI-powered conversations with your customers.'
|
||||||
@@ -32,6 +34,15 @@ disable_branding:
|
|||||||
enabled: <%= (ChatwootHub.pricing_plan != 'community') %>
|
enabled: <%= (ChatwootHub.pricing_plan != 'community') %>
|
||||||
icon: 'icon-sailbot-fill'
|
icon: 'icon-sailbot-fill'
|
||||||
enterprise: true
|
enterprise: true
|
||||||
|
|
||||||
|
# ------- Product Features ------- #
|
||||||
|
help_center:
|
||||||
|
name: 'Help Center'
|
||||||
|
description: 'Allow agents to create help center articles and publish them in a portal.'
|
||||||
|
enabled: true
|
||||||
|
icon: 'icon-book-2-line'
|
||||||
|
|
||||||
|
# ------- Communication Channels ------- #
|
||||||
live_chat:
|
live_chat:
|
||||||
name: 'Live Chat'
|
name: 'Live Chat'
|
||||||
description: 'Improve your customer experience using a live chat on your website.'
|
description: 'Improve your customer experience using a live chat on your website.'
|
||||||
@@ -42,12 +53,24 @@ email:
|
|||||||
description: 'Manage your email customer interactions from Chatwoot.'
|
description: 'Manage your email customer interactions from Chatwoot.'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-mail-send-fill'
|
icon: 'icon-mail-send-fill'
|
||||||
|
config_key: 'email'
|
||||||
|
sms:
|
||||||
|
name: 'SMS'
|
||||||
|
description: 'Manage your SMS customer interactions from Chatwoot.'
|
||||||
|
enabled: true
|
||||||
|
icon: 'icon-message-line'
|
||||||
messenger:
|
messenger:
|
||||||
name: 'Messenger'
|
name: 'Messenger'
|
||||||
description: 'Stay connected with your customers on Facebook & Instagram.'
|
description: 'Stay connected with your customers on Facebook & Instagram.'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-messenger-line'
|
icon: 'icon-messenger-line'
|
||||||
config_key: 'facebook'
|
config_key: 'facebook'
|
||||||
|
instagram:
|
||||||
|
name: 'Instagram'
|
||||||
|
description: 'Stay connected with your customers on Instagram'
|
||||||
|
enabled: true
|
||||||
|
icon: 'icon-instagram'
|
||||||
|
config_key: 'instagram'
|
||||||
whatsapp:
|
whatsapp:
|
||||||
name: 'WhatsApp'
|
name: 'WhatsApp'
|
||||||
description: 'Manage your WhatsApp business interactions from Chatwoot.'
|
description: 'Manage your WhatsApp business interactions from Chatwoot.'
|
||||||
@@ -63,37 +86,49 @@ line:
|
|||||||
description: 'Manage your Line customer interactions from Chatwoot.'
|
description: 'Manage your Line customer interactions from Chatwoot.'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-line-line'
|
icon: 'icon-line-line'
|
||||||
sms:
|
|
||||||
name: 'SMS'
|
# ------- OAuth & Authentication ------- #
|
||||||
description: 'Manage your SMS customer interactions from Chatwoot.'
|
google:
|
||||||
|
name: 'Google'
|
||||||
|
description: 'Configuration for setting up Google OAuth Integration'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-message-line'
|
icon: 'icon-google'
|
||||||
help_center:
|
config_key: 'google'
|
||||||
name: 'Help Center'
|
|
||||||
description: 'Allow agents to create help center articles and publish them in a portal.'
|
|
||||||
enabled: true
|
|
||||||
icon: 'icon-book-2-line'
|
|
||||||
microsoft:
|
microsoft:
|
||||||
name: 'Microsoft'
|
name: 'Microsoft'
|
||||||
description: 'Configuration for setting up Microsoft Email'
|
description: 'Configuration for setting up Microsoft Email'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-microsoft'
|
icon: 'icon-microsoft'
|
||||||
config_key: 'microsoft'
|
config_key: 'microsoft'
|
||||||
|
|
||||||
|
# ------- Third-party Integrations ------- #
|
||||||
linear:
|
linear:
|
||||||
name: 'Linear'
|
name: 'Linear'
|
||||||
description: 'Configuration for setting up Linear'
|
description: 'Configuration for setting up Linear Integration'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-linear'
|
icon: 'icon-linear'
|
||||||
config_key: 'linear'
|
config_key: 'linear'
|
||||||
instagram:
|
notion:
|
||||||
name: 'Instagram'
|
name: 'Notion'
|
||||||
description: 'Configuration for setting up Instagram'
|
description: 'Configuration for setting up Notion Integration'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-instagram'
|
icon: 'icon-notion'
|
||||||
config_key: 'instagram'
|
config_key: 'notion'
|
||||||
|
slack:
|
||||||
|
name: 'Slack'
|
||||||
|
description: 'Configuration for setting up Slack Integration'
|
||||||
|
enabled: true
|
||||||
|
icon: 'icon-slack'
|
||||||
|
config_key: 'slack'
|
||||||
|
whatsapp_embedded:
|
||||||
|
name: 'WhatsApp Embedded'
|
||||||
|
description: 'Configuration for setting up WhatsApp Embedded Integration'
|
||||||
|
enabled: true
|
||||||
|
icon: 'icon-whatsapp-line'
|
||||||
|
config_key: 'whatsapp_embedded'
|
||||||
shopify:
|
shopify:
|
||||||
name: 'Shopify'
|
name: 'Shopify'
|
||||||
description: 'Configuration for setting up Shopify'
|
description: 'Configuration for setting up Shopify Integration'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-shopify'
|
icon: 'icon-shopify'
|
||||||
config_key: 'shopify'
|
config_key: 'shopify'
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
module SuperAdmin::FeaturesHelper
|
module SuperAdmin::FeaturesHelper
|
||||||
def self.available_features
|
def self.available_features
|
||||||
YAML.load(ERB.new(Rails.root.join('enterprise/app/helpers/super_admin/features.yml').read).result).with_indifferent_access
|
YAML.load(ERB.new(Rails.root.join('app/helpers/super_admin/features.yml').read).result).with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.plan_details
|
def self.plan_details
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
module SuperAdmin::NavigationHelper
|
||||||
|
def settings_open?
|
||||||
|
params[:controller].in? %w[super_admin/settings super_admin/app_configs]
|
||||||
|
end
|
||||||
|
|
||||||
|
def settings_pages
|
||||||
|
features = SuperAdmin::FeaturesHelper.available_features.select do |_feature, attrs|
|
||||||
|
attrs['config_key'].present? && attrs['enabled']
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add general at the beginning
|
||||||
|
general_feature = [['general', { 'config_key' => 'general', 'name' => 'General' }]]
|
||||||
|
|
||||||
|
general_feature + features.to_a
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import AddAccountModal from '../dashboard/components/layout/sidebarComponents/AddAccountModal.vue';
|
import AddAccountModal from './components/app/AddAccountModal.vue';
|
||||||
import LoadingState from './components/widgets/LoadingState.vue';
|
import LoadingState from './components/widgets/LoadingState.vue';
|
||||||
import NetworkNotification from './components/NetworkNotification.vue';
|
import NetworkNotification from './components/NetworkNotification.vue';
|
||||||
import UpdateBanner from './components/app/UpdateBanner.vue';
|
import UpdateBanner from './components/app/UpdateBanner.vue';
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class AgentBotsAPI extends ApiClient {
|
|||||||
deleteAgentBotAvatar(botId) {
|
deleteAgentBotAvatar(botId) {
|
||||||
return axios.delete(`${this.url}/${botId}/avatar`);
|
return axios.delete(`${this.url}/${botId}/avatar`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetAccessToken(botId) {
|
||||||
|
return axios.post(`${this.url}/${botId}/reset_access_token`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new AgentBotsAPI();
|
export default new AgentBotsAPI();
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from './ApiClient';
|
||||||
|
|
||||||
|
export class AgentCapacityPoliciesAPI extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('agent_capacity_policies', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/agent_capacity_policies
|
||||||
|
get(params = {}) {
|
||||||
|
return axios.get(this.url, { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/agent_capacity_policies/:id
|
||||||
|
show(id) {
|
||||||
|
return axios.get(`${this.url}/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/agent_capacity_policies
|
||||||
|
create(data) {
|
||||||
|
return axios.post(this.url, { agent_capacity_policy: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT /api/v1/accounts/:accountId/agent_capacity_policies/:id
|
||||||
|
update(id, data) {
|
||||||
|
return axios.put(`${this.url}/${id}`, { agent_capacity_policy: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /api/v1/accounts/:accountId/agent_capacity_policies/:id
|
||||||
|
delete(id) {
|
||||||
|
return axios.delete(`${this.url}/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/agent_capacity_policies/:id/users
|
||||||
|
assignUser(id, userId) {
|
||||||
|
return axios.post(`${this.url}/${id}/users`, {
|
||||||
|
user_id: userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /api/v1/accounts/:accountId/agent_capacity_policies/:id/users/:userId
|
||||||
|
removeUser(id, userId) {
|
||||||
|
return axios.delete(`${this.url}/${id}/users/${userId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/agent_capacity_policies/:id/inbox_limits/:inboxId
|
||||||
|
setInboxLimit(id, inboxId, conversationLimit) {
|
||||||
|
return axios.post(`${this.url}/${id}/inbox_limits/${inboxId}`, {
|
||||||
|
conversation_limit: conversationLimit,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /api/v1/accounts/:accountId/agent_capacity_policies/:id/inbox_limits/:inboxId
|
||||||
|
removeInboxLimit(id, inboxId) {
|
||||||
|
return axios.delete(`${this.url}/${id}/inbox_limits/${inboxId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/agents/:agentId/capacity
|
||||||
|
getAgentCapacity(accountId, agentId, inboxId = null) {
|
||||||
|
const url = `/api/v1/accounts/${accountId}/agents/${agentId}/capacity`;
|
||||||
|
const params = inboxId ? { inbox_id: inboxId } : {};
|
||||||
|
return axios.get(url, { params });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new AgentCapacityPoliciesAPI();
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from './ApiClient';
|
||||||
|
|
||||||
|
export class AssignmentMetricsAPI extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('reports/assignment_metrics', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/reports/assignment_metrics
|
||||||
|
get(params = {}) {
|
||||||
|
return axios.get(this.url, { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/agents/:userId/assignment_history
|
||||||
|
getAgentHistory(userId, params = {}) {
|
||||||
|
return axios.get(
|
||||||
|
`/api/v1/accounts/${this.accountId}/agents/${userId}/assignment_history`,
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all agents assignment history
|
||||||
|
getAllAgentsHistory(params = {}) {
|
||||||
|
return axios.get(this.url, {
|
||||||
|
params: { ...params, include_agent_history: true },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get policy performance metrics
|
||||||
|
getPolicyPerformance(params = {}) {
|
||||||
|
return axios.get(this.url, {
|
||||||
|
params: { ...params, include_policy_performance: true },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get agent utilization metrics
|
||||||
|
getAgentUtilization(params = {}) {
|
||||||
|
return axios.get(this.url, {
|
||||||
|
params: { ...params, include_utilization: true },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export report data
|
||||||
|
exportReport(type, params = {}) {
|
||||||
|
return axios.get(`${this.url}/export`, {
|
||||||
|
params: { type, ...params },
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new AssignmentMetricsAPI();
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from './ApiClient';
|
||||||
|
|
||||||
|
export class AssignmentPoliciesAPI extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('assignment_policies', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/assignment_policies
|
||||||
|
get() {
|
||||||
|
return axios.get(this.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/assignment_policies/:id
|
||||||
|
show(id) {
|
||||||
|
return axios.get(`${this.url}/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/assignment_policies
|
||||||
|
create(data) {
|
||||||
|
return axios.post(this.url, { assignment_policy: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT /api/v1/accounts/:accountId/assignment_policies/:id
|
||||||
|
update(id, data) {
|
||||||
|
return axios.put(`${this.url}/${id}`, { assignment_policy: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /api/v1/accounts/:accountId/assignment_policies/:id
|
||||||
|
delete(id) {
|
||||||
|
return axios.delete(`${this.url}/${id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new AssignmentPoliciesAPI();
|
||||||
@@ -38,13 +38,7 @@ export default {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
profileUpdate({
|
profileUpdate({ displayName, avatar, ...profileAttributes }) {
|
||||||
password,
|
|
||||||
password_confirmation,
|
|
||||||
displayName,
|
|
||||||
avatar,
|
|
||||||
...profileAttributes
|
|
||||||
}) {
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
Object.keys(profileAttributes).forEach(key => {
|
Object.keys(profileAttributes).forEach(key => {
|
||||||
const hasValue = profileAttributes[key] === undefined;
|
const hasValue = profileAttributes[key] === undefined;
|
||||||
@@ -53,16 +47,22 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
formData.append('profile[display_name]', displayName || '');
|
formData.append('profile[display_name]', displayName || '');
|
||||||
if (password && password_confirmation) {
|
|
||||||
formData.append('profile[password]', password);
|
|
||||||
formData.append('profile[password_confirmation]', password_confirmation);
|
|
||||||
}
|
|
||||||
if (avatar) {
|
if (avatar) {
|
||||||
formData.append('profile[avatar]', avatar);
|
formData.append('profile[avatar]', avatar);
|
||||||
}
|
}
|
||||||
return axios.put(endPoints('profileUpdate').url, formData);
|
return axios.put(endPoints('profileUpdate').url, formData);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
profilePasswordUpdate({ currentPassword, password, passwordConfirmation }) {
|
||||||
|
return axios.put(endPoints('profileUpdate').url, {
|
||||||
|
profile: {
|
||||||
|
current_password: currentPassword,
|
||||||
|
password,
|
||||||
|
password_confirmation: passwordConfirmation,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
updateUISettings({ uiSettings }) {
|
updateUISettings({ uiSettings }) {
|
||||||
return axios.put(endPoints('profileUpdate').url, {
|
return axios.put(endPoints('profileUpdate').url, {
|
||||||
profile: { ui_settings: uiSettings },
|
profile: { ui_settings: uiSettings },
|
||||||
@@ -102,4 +102,8 @@ export default {
|
|||||||
const urlData = endPoints('resendConfirmation');
|
const urlData = endPoints('resendConfirmation');
|
||||||
return axios.post(urlData.url);
|
return axios.post(urlData.url);
|
||||||
},
|
},
|
||||||
|
resetAccessToken() {
|
||||||
|
const urlData = endPoints('resetAccessToken');
|
||||||
|
return axios.post(urlData.url);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from '../ApiClient';
|
||||||
|
|
||||||
|
class CopilotMessages extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('captain/copilot_threads', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
get(threadId) {
|
||||||
|
return axios.get(`${this.url}/${threadId}/copilot_messages`);
|
||||||
|
}
|
||||||
|
|
||||||
|
create({ threadId, ...rest }) {
|
||||||
|
return axios.post(`${this.url}/${threadId}/copilot_messages`, rest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new CopilotMessages();
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import ApiClient from '../ApiClient';
|
||||||
|
|
||||||
|
class CopilotThreads extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('captain/copilot_threads', { accountScoped: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new CopilotThreads();
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from '../ApiClient';
|
||||||
|
|
||||||
|
class WhatsappChannel extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('whatsapp', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
createEmbeddedSignup(params) {
|
||||||
|
return axios.post(`${this.baseUrl()}/whatsapp/authorization`, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new WhatsappChannel();
|
||||||
@@ -61,6 +61,11 @@ class ContactAPI extends ApiClient {
|
|||||||
return axios.get(requestURL);
|
return axios.get(requestURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
active(page = 1, sortAttr = 'name') {
|
||||||
|
let requestURL = `${this.url}/active?${buildContactParams(page, sortAttr)}`;
|
||||||
|
return axios.get(requestURL);
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line default-param-last
|
// eslint-disable-next-line default-param-last
|
||||||
filter(page = 1, sortAttr = 'name', queryPayload) {
|
filter(page = 1, sortAttr = 'name', queryPayload) {
|
||||||
let requestURL = `${this.url}/filter?${buildContactParams(page, sortAttr)}`;
|
let requestURL = `${this.url}/filter?${buildContactParams(page, sortAttr)}`;
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ const endPoints = {
|
|||||||
resendConfirmation: {
|
resendConfirmation: {
|
||||||
url: '/api/v1/profile/resend_confirmation',
|
url: '/api/v1/profile/resend_confirmation',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetAccessToken: {
|
||||||
|
url: '/api/v1/profile/reset_access_token',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default page => {
|
export default page => {
|
||||||
|
|||||||
@@ -137,6 +137,10 @@ class ConversationApi extends ApiClient {
|
|||||||
getInboxAssistant(conversationId) {
|
getInboxAssistant(conversationId) {
|
||||||
return axios.get(`${this.url}/${conversationId}/inbox_assistant`);
|
return axios.get(`${this.url}/${conversationId}/inbox_assistant`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(conversationId) {
|
||||||
|
return axios.delete(`${this.url}/${conversationId}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new ConversationApi();
|
export default new ConversationApi();
|
||||||
|
|||||||
@@ -28,6 +28,20 @@ class Inboxes extends CacheEnabledApiClient {
|
|||||||
agent_bot: botId,
|
agent_bot: botId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncTemplates(inboxId) {
|
||||||
|
return axios.post(`${this.url}/${inboxId}/sync_templates`);
|
||||||
|
}
|
||||||
|
|
||||||
|
assignPolicy(inboxId, policyId) {
|
||||||
|
return axios.post(`${this.url}/${inboxId}/assignment_policy`, {
|
||||||
|
assignment_policy_id: policyId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
removePolicy(inboxId) {
|
||||||
|
return axios.delete(`${this.url}/${inboxId}/assignment_policy`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Inboxes();
|
export default new Inboxes();
|
||||||
|
|||||||
@@ -33,9 +33,11 @@ class LinearAPI extends ApiClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unlinkIssue(linkId) {
|
unlinkIssue(linkId, issueIdentifier, conversationId) {
|
||||||
return axios.post(`${this.url}/unlink_issue`, {
|
return axios.post(`${this.url}/unlink_issue`, {
|
||||||
link_id: linkId,
|
link_id: linkId,
|
||||||
|
issue_id: issueIdentifier,
|
||||||
|
conversation_id: conversationId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from './ApiClient';
|
||||||
|
|
||||||
|
export class LeavesAPI extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('leaves', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/leaves
|
||||||
|
get(params = {}) {
|
||||||
|
return axios.get(this.url, { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/leaves/:id
|
||||||
|
show(id) {
|
||||||
|
return axios.get(`${this.url}/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/leaves
|
||||||
|
create(data) {
|
||||||
|
return axios.post(this.url, { leave: data.leave, user_id: data.user_id });
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT /api/v1/accounts/:accountId/leaves/:id
|
||||||
|
update(id, data) {
|
||||||
|
return axios.put(`${this.url}/${id}`, { leave: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /api/v1/accounts/:accountId/leaves/:id
|
||||||
|
delete(id) {
|
||||||
|
return axios.delete(`${this.url}/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/leaves/:id/approve
|
||||||
|
approve(id, data = {}) {
|
||||||
|
return axios.post(`${this.url}/${id}/approve`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /api/v1/accounts/:accountId/leaves/:id/reject
|
||||||
|
reject(id, data = {}) {
|
||||||
|
return axios.post(`${this.url}/${id}/reject`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/leaves/my_leaves
|
||||||
|
getMyLeaves(params = {}) {
|
||||||
|
return axios.get(`${this.url}/my_leaves`, { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /api/v1/accounts/:accountId/leaves/pending_approvals
|
||||||
|
getPendingApprovals(params = {}) {
|
||||||
|
return axios.get(`${this.url}/pending_approvals`, { params });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new LeavesAPI();
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/* global axios */
|
||||||
|
import ApiClient from './ApiClient';
|
||||||
|
|
||||||
|
class NotionOAuthClient extends ApiClient {
|
||||||
|
constructor() {
|
||||||
|
super('notion', { accountScoped: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
generateAuthorization() {
|
||||||
|
return axios.post(`${this.url}/authorization`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new NotionOAuthClient();
|
||||||
@@ -40,6 +40,15 @@ class SearchAPI extends ApiClient {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
articles({ q, page = 1 }) {
|
||||||
|
return axios.get(`${this.url}/articles`, {
|
||||||
|
params: {
|
||||||
|
q,
|
||||||
|
page: page,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new SearchAPI();
|
export default new SearchAPI();
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ describe('#AgentBotsAPI', () => {
|
|||||||
expect(AgentBotsAPI).toHaveProperty('create');
|
expect(AgentBotsAPI).toHaveProperty('create');
|
||||||
expect(AgentBotsAPI).toHaveProperty('update');
|
expect(AgentBotsAPI).toHaveProperty('update');
|
||||||
expect(AgentBotsAPI).toHaveProperty('delete');
|
expect(AgentBotsAPI).toHaveProperty('delete');
|
||||||
|
expect(AgentBotsAPI).toHaveProperty('resetAccessToken');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ describe('#InboxesAPI', () => {
|
|||||||
expect(inboxesAPI).toHaveProperty('getCampaigns');
|
expect(inboxesAPI).toHaveProperty('getCampaigns');
|
||||||
expect(inboxesAPI).toHaveProperty('getAgentBot');
|
expect(inboxesAPI).toHaveProperty('getAgentBot');
|
||||||
expect(inboxesAPI).toHaveProperty('setAgentBot');
|
expect(inboxesAPI).toHaveProperty('setAgentBot');
|
||||||
|
expect(inboxesAPI).toHaveProperty('syncTemplates');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('API calls', () => {
|
describe('API calls', () => {
|
||||||
@@ -40,5 +41,12 @@ describe('#InboxesAPI', () => {
|
|||||||
inboxesAPI.deleteInboxAvatar(2);
|
inboxesAPI.deleteInboxAvatar(2);
|
||||||
expect(axiosMock.delete).toHaveBeenCalledWith('/api/v1/inboxes/2/avatar');
|
expect(axiosMock.delete).toHaveBeenCalledWith('/api/v1/inboxes/2/avatar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('#syncTemplates', () => {
|
||||||
|
inboxesAPI.syncTemplates(2);
|
||||||
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||||
|
'/api/v1/inboxes/2/sync_templates'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -91,6 +91,19 @@ describe('#linearAPI', () => {
|
|||||||
issueData
|
issueData
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('creates a valid request with conversation_id', () => {
|
||||||
|
const issueData = {
|
||||||
|
title: 'New Issue',
|
||||||
|
description: 'Issue description',
|
||||||
|
conversation_id: 123,
|
||||||
|
};
|
||||||
|
LinearAPIClient.createIssue(issueData);
|
||||||
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||||
|
'/api/v1/integrations/linear/create_issue',
|
||||||
|
issueData
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('link_issue', () => {
|
describe('link_issue', () => {
|
||||||
@@ -120,6 +133,18 @@ describe('#linearAPI', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('creates a valid request with title', () => {
|
||||||
|
LinearAPIClient.link_issue(1, 'ENG-123', 'Sample Issue');
|
||||||
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||||
|
'/api/v1/integrations/linear/link_issue',
|
||||||
|
{
|
||||||
|
issue_id: 'ENG-123',
|
||||||
|
conversation_id: 1,
|
||||||
|
title: 'Sample Issue',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getLinkedIssue', () => {
|
describe('getLinkedIssue', () => {
|
||||||
@@ -164,12 +189,26 @@ describe('#linearAPI', () => {
|
|||||||
window.axios = originalAxios;
|
window.axios = originalAxios;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates a valid request', () => {
|
it('creates a valid request with link_id only', () => {
|
||||||
LinearAPIClient.unlinkIssue(1);
|
LinearAPIClient.unlinkIssue('link123');
|
||||||
expect(axiosMock.post).toHaveBeenCalledWith(
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||||
'/api/v1/integrations/linear/unlink_issue',
|
'/api/v1/integrations/linear/unlink_issue',
|
||||||
{
|
{
|
||||||
link_id: 1,
|
link_id: 'link123',
|
||||||
|
issue_id: undefined,
|
||||||
|
conversation_id: undefined,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates a valid request with all parameters', () => {
|
||||||
|
LinearAPIClient.unlinkIssue('link123', 'ENG-456', 789);
|
||||||
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||||
|
'/api/v1/integrations/linear/unlink_issue',
|
||||||
|
{
|
||||||
|
link_id: 'link123',
|
||||||
|
issue_id: 'ENG-456',
|
||||||
|
conversation_id: 789,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,6 +35,16 @@ class SummaryReportsAPI extends ApiClient {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLabelReports({ since, until, businessHours } = {}) {
|
||||||
|
return axios.get(`${this.url}/label`, {
|
||||||
|
params: {
|
||||||
|
since,
|
||||||
|
until,
|
||||||
|
business_hours: businessHours,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new SummaryReportsAPI();
|
export default new SummaryReportsAPI();
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
.slide-fade-enter-active {
|
|
||||||
transition: all 0.3s var(--ease-in-cubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-fade-leave-active {
|
|
||||||
transition: all 0.3s var(--ease-out-cubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-fade-enter,
|
|
||||||
.slide-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateX(10px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-fade-enter {
|
|
||||||
transform: translateX($space-micro);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-fade-leave-to {
|
|
||||||
transform: translateX($space-medium);
|
|
||||||
}
|
|
||||||
|
|
||||||
.conversations-list-enter-active,
|
|
||||||
.conversations-list-leave-active {
|
|
||||||
transition: all 0.25s var(--ease-out-cubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
.conversations-list-enter,
|
|
||||||
.conversations-list-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateX($space-medium);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-up-enter-active {
|
|
||||||
transition: all 0.3s var(--ease-in-cubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-up-leave-active {
|
|
||||||
transition: all 0.3s var(--ease-out-cubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slide-up-enter,
|
|
||||||
.slide-up-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-$space-medium);
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-slide-enter-active,
|
|
||||||
.menu-slide-leave-active {
|
|
||||||
transform: translateY(0);
|
|
||||||
transition:
|
|
||||||
transform 0.25s var(--ease-in-cubic),
|
|
||||||
opacity 0.15s var(--ease-in-cubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-slide-enter,
|
|
||||||
.menu-slide-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY($space-small);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast-fade-enter-active {
|
|
||||||
transition: all 0.3s var(--ease-in-sine);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast-fade-leave-active {
|
|
||||||
transition: all 0.1s var(--ease-out-sine);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast-fade-enter,
|
|
||||||
.toast-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-$space-small);
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-fade-enter-active {
|
|
||||||
transition: all 0.3s var(--ease-in-sine);
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-fade-leave-active {
|
|
||||||
transition: all 0.1s var(--ease-out-sine);
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-fade-enter,
|
|
||||||
.modal-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.network-notification-fade-enter-active {
|
|
||||||
transition: all 0.1s var(--ease-in-sine);
|
|
||||||
}
|
|
||||||
|
|
||||||
.network-notification-fade-leave-active {
|
|
||||||
transition: all 0.1s var(--ease-out-sine);
|
|
||||||
}
|
|
||||||
|
|
||||||
.network-notification-fade-enter,
|
|
||||||
.network-notification-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-$space-small);
|
|
||||||
}
|
|
||||||
+6
-1
@@ -101,7 +101,7 @@ select {
|
|||||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='32' height='24' viewBox='0 0 32 24'><polygon points='0,0 32,0 16,24' style='fill: rgb%28110, 111, 115%29'></polygon></svg>");
|
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='32' height='24' viewBox='0 0 32 24'><polygon points='0,0 32,0 16,24' style='fill: rgb%28110, 111, 115%29'></polygon></svg>");
|
||||||
background-size: 9px 6px;
|
background-size: 9px 6px;
|
||||||
|
|
||||||
@apply field-base h-10 bg-origin-content focus-visible:outline-none bg-no-repeat py-2 ltr:bg-[right_-1rem_center] rtl:bg-[left_-1rem_center] ltr:pr-6 rtl:pl-6 rtl:pr-3 ltr:pl-3;
|
@apply field-base h-10 bg-origin-content bg-no-repeat py-2 ltr:bg-[right_-1rem_center] rtl:bg-[left_-1rem_center] ltr:pr-6 rtl:pl-6 rtl:pr-3 ltr:pl-3;
|
||||||
|
|
||||||
&[disabled] {
|
&[disabled] {
|
||||||
@apply field-disabled;
|
@apply field-disabled;
|
||||||
@@ -201,3 +201,8 @@ code {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Table
|
||||||
|
table {
|
||||||
|
@apply border-spacing-0 text-sm w-full;
|
||||||
|
}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
@import 'dashboard/assets/scss/variables';
|
|
||||||
|
|
||||||
.formulate-input {
|
|
||||||
.formulate-input-errors {
|
|
||||||
list-style-type: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formulate-input-error {
|
|
||||||
color: var(--r-400);
|
|
||||||
display: block;
|
|
||||||
font-size: var(--font-size-small);
|
|
||||||
font-weight: $font-weight-normal;
|
|
||||||
margin-bottom: $space-one;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.integration-hooks {
|
|
||||||
.formulate-input[data-type='checkbox'] {
|
|
||||||
.formulate-input-wrapper {
|
|
||||||
@apply flex;
|
|
||||||
|
|
||||||
.formulate-input-element {
|
|
||||||
@apply pr-2;
|
|
||||||
|
|
||||||
input {
|
|
||||||
@apply mb-0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.formulate-input-element-decorator {
|
|
||||||
@apply hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
// loader class
|
|
||||||
.spinner {
|
|
||||||
@include color-spinner();
|
|
||||||
@apply inline-block h-6 py-0 px-6 relative align-middle w-6;
|
|
||||||
|
|
||||||
&.message {
|
|
||||||
@apply bg-white dark:bg-slate-800 rounded-full left-0 my-3 mx-auto p-4 top-0;
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
@apply -ml-3 -mt-3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.small {
|
|
||||||
@apply h-4 w-4;
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
@apply h-4 -mt-2 w-4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user