Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd079fe4a0 | |||
| b50779ac28 |
@@ -1,49 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the Bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Send request to API: [specify endpoint, include payload example]
|
||||
2. Go to '...'
|
||||
3. Click on '....'
|
||||
4. Scroll down to '....'
|
||||
5. See error
|
||||
|
||||
**Expected vs Actual Behavior**
|
||||
- Expected: A clear and concise description of what you expected to happen.
|
||||
- Actual: A clear and concise description of what actually happened.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Environment**
|
||||
- App Version: [e.g., 1.16.0]
|
||||
- Mode: [Local, Cloud, Private]
|
||||
- Operation: [sending/receiving SMS]
|
||||
- Integration: [e.g., CLI, API, PHP client, etc.]
|
||||
- Network Type: [WiFi/Mobile Data]
|
||||
|
||||
**Smartphone**
|
||||
- Device: [e.g., Google Pixel]
|
||||
- OS: [e.g., Android 11]
|
||||
- SIM Card Count: [e.g., 1 or 2] (Please specify the number of active SIM cards in the device)
|
||||
|
||||
**Additional Context**
|
||||
Add any other context about the problem here, such as log file excerpts.
|
||||
|
||||
**Checklist Before Submission**
|
||||
- [ ] I have described the bug in detail.
|
||||
- [ ] I have provided the steps to reproduce.
|
||||
- [ ] I have included screenshots (if applicable).
|
||||
- [ ] I have provided environment details.
|
||||
- [ ] I have included relevant log file excerpts (if applicable).
|
||||
- [ ] I have read [FAQ](https://sms-gate.app/faq/general/) and other relevant information.
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,94 +0,0 @@
|
||||
name: Build APK
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version-name:
|
||||
required: true
|
||||
type: string
|
||||
build-type:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
google-services-json:
|
||||
required: true
|
||||
signing-key-store-base64:
|
||||
required: true
|
||||
signing-key-alias:
|
||||
required: true
|
||||
signing-key-password:
|
||||
required: true
|
||||
signing-store-password:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build-apk:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup JAVA 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
|
||||
- name: Cache Gradle and wrapper
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
||||
|
||||
- name: Setup Google Services
|
||||
run: echo ${{ secrets.google-services-json }} | base64 --decode > ./app/google-services.json
|
||||
|
||||
- name: Set App Version
|
||||
run: |
|
||||
export VERSION_NAME='${{ inputs.version-name }}'
|
||||
sed -i "s/versionName.*/versionName \"${VERSION_NAME#v}\"/" app/build.gradle
|
||||
sed -i "s/versionCode.*/versionCode $(( ($(date +%s) - $(date -d "2022-06-15" +%s)) / 86400 ))/" app/build.gradle
|
||||
|
||||
- name: Test
|
||||
run: ./gradlew test
|
||||
|
||||
#1
|
||||
- name: Decode Keystore
|
||||
env:
|
||||
ENCODED_STRING: ${{ secrets.signing-key-store-base64 }}
|
||||
SIGNING_KEY_STORE_PATH: app/keystore.jks
|
||||
|
||||
run: |
|
||||
echo $ENCODED_STRING > keystore-b64.txt
|
||||
base64 -d keystore-b64.txt > $SIGNING_KEY_STORE_PATH
|
||||
|
||||
#2
|
||||
- name: Build ${{ inputs.build-type }} apk
|
||||
env:
|
||||
SIGNING_KEY_STORE_PATH: app/keystore.jks
|
||||
SIGNING_KEY_ALIAS: ${{ secrets.signing-key-alias }}
|
||||
SIGNING_KEY_PASSWORD: ${{ secrets.signing-key-password }}
|
||||
SIGNING_STORE_PASSWORD: ${{ secrets.signing-store-password }}
|
||||
TARGET: ${{ inputs.build-type }}
|
||||
run: ./gradlew assemble${TARGET^}
|
||||
|
||||
- name: Build ${{ inputs.build-type }} bundle
|
||||
env:
|
||||
SIGNING_KEY_STORE_PATH: app/keystore.jks
|
||||
SIGNING_KEY_ALIAS: ${{ secrets.signing-key-alias }}
|
||||
SIGNING_KEY_PASSWORD: ${{ secrets.signing-key-password }}
|
||||
SIGNING_STORE_PASSWORD: ${{ secrets.signing-store-password }}
|
||||
TARGET: ${{ inputs.build-type }}
|
||||
run: ./gradlew bundle${TARGET^}
|
||||
#3
|
||||
- name: Upload ${{ inputs.build-type }} Build to Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs.build-type }}-artifacts
|
||||
path: |
|
||||
app/build/outputs/apk/${{ inputs.build-type }}/
|
||||
app/build/outputs/bundle/${{ inputs.build-type }}/
|
||||
@@ -1,25 +0,0 @@
|
||||
name: Close inactive issues and PRs
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 1 * * *"
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v10
|
||||
with:
|
||||
days-before-stale: 7
|
||||
days-before-close: 7
|
||||
exempt-all-assignees: true
|
||||
|
||||
stale-issue-message: "This issue is stale because it has been open for 7 days with no activity."
|
||||
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
|
||||
stale-issue-label: "stale"
|
||||
|
||||
stale-pr-message: "This PR is stale because it has been open for 7 days with no activity."
|
||||
close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale."
|
||||
stale-pr-label: "stale"
|
||||
@@ -1,22 +0,0 @@
|
||||
name: Discord Release Notification
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
notify-discord:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.release.prerelease == false
|
||||
steps:
|
||||
- name: Send Discord Notification
|
||||
uses: capcom6/discord-webhook@3a447f4ed76c79ed32fb073d705bda1cd45119e6
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
content: |
|
||||
🎉 New Release of [${{ github.event.repository.name }}](${{ github.event.repository.html_url }}): **${{ github.event.release.name }}**
|
||||
|
||||
${{ github.event.release.body }}
|
||||
|
||||
📦 Download: ${{ github.event.release.html_url }}
|
||||
flags: 4 # 4 = SUPPRESS_EMBEDS
|
||||
@@ -1,22 +0,0 @@
|
||||
name: Publish Docs
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Set App Version
|
||||
run: |
|
||||
sed -i "s/{{VERSION}}/${GITHUB_REF_NAME#v}/" docs/api/swagger.json
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./docs/api
|
||||
@@ -1,78 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
pull_request: { types: [opened, synchronize, ready_for_review] }
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
build-type: [release, insecure]
|
||||
name: Build ${{ matrix.build-type }}
|
||||
if: github.event.pull_request.draft == false
|
||||
uses: ./.github/workflows/build-apk.yml
|
||||
with:
|
||||
version-name: ${{ github.sha }}
|
||||
build-type: ${{ matrix.build-type }}
|
||||
secrets:
|
||||
google-services-json: ${{ secrets.GOOGLE_SERVICES_JSON }}
|
||||
signing-key-store-base64: ${{ secrets.SIGNING_KEY_STORE_BASE64 }}
|
||||
signing-key-alias: ${{ secrets.SIGNING_KEY_ALIAS }}
|
||||
signing-key-password: ${{ secrets.SIGNING_KEY_PASSWORD }}
|
||||
signing-store-password: ${{ secrets.SIGNING_STORE_PASSWORD }}
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.draft == false
|
||||
needs: [build]
|
||||
steps:
|
||||
- name: Download release artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-artifacts
|
||||
|
||||
- name: Download insecure artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: insecure-artifacts
|
||||
|
||||
- name: Upload to S3
|
||||
uses: capcom6/upload-s3-action@master
|
||||
env:
|
||||
AWS_REGION: ${{ secrets.AWS_REGION }}
|
||||
with:
|
||||
aws_key_id: ${{ secrets.AWS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
||||
aws_bucket: ${{ secrets.AWS_BUCKET }}
|
||||
endpoint: ${{ secrets.AWS_ENDPOINT }}
|
||||
source_files: |
|
||||
./apk/release/app-release.apk
|
||||
./bundle/release/app-release.aab
|
||||
./apk/insecure/app-insecure.apk
|
||||
./bundle/insecure/app-insecure.aab
|
||||
destination_dir: apk/${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Find Comment
|
||||
uses: peter-evans/find-comment@v3
|
||||
id: fc
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-author: "github-actions[bot]"
|
||||
body-includes: Pull request artifacts
|
||||
|
||||
- name: Create or update comment
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
with:
|
||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body: |
|
||||
## 🤖 Pull request artifacts
|
||||
|
||||
| file | commit |
|
||||
| ---- | ------ |
|
||||
| [`app-release.apk`](https://s3.sms-gate.app/apk/${{ github.event.pull_request.head.sha }}/app-release.apk) | ${{ github.event.pull_request.head.sha }} |
|
||||
| [`app-release.aab`](https://s3.sms-gate.app/apk/${{ github.event.pull_request.head.sha }}/app-release.aab) | ${{ github.event.pull_request.head.sha }} |
|
||||
| [`app-insecure.apk`](https://s3.sms-gate.app/apk/${{ github.event.pull_request.head.sha }}/app-insecure.apk) | ${{ github.event.pull_request.head.sha }} |
|
||||
| [`app-insecure.aab`](https://s3.sms-gate.app/apk/${{ github.event.pull_request.head.sha }}/app-insecure.aab) | ${{ github.event.pull_request.head.sha }} |
|
||||
|
||||
edit-mode: replace
|
||||
@@ -1,23 +0,0 @@
|
||||
name: Remove Labels on New Push
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize] # Trigger on PR opened or new commits pushed
|
||||
|
||||
jobs:
|
||||
remove_labels:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write # Grant permission to modify labels
|
||||
steps:
|
||||
# step 1: checkout repository code
|
||||
- name: Checkout code into workspace directory
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# step 2: remove specific labels
|
||||
- name: Remove specific labels
|
||||
run: |
|
||||
gh pr edit ${{ github.event.pull_request.number }} --remove-label "ready" || true
|
||||
gh pr edit ${{ github.event.pull_request.number }} --remove-label "deployed" || true
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,43 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
build-type: [release, insecure]
|
||||
name: Build ${{ matrix.build-type }}
|
||||
uses: ./.github/workflows/build-apk.yml
|
||||
with:
|
||||
version-name: ${{ github.ref_name }}
|
||||
build-type: ${{ matrix.build-type }}
|
||||
secrets:
|
||||
google-services-json: ${{ secrets.GOOGLE_SERVICES_JSON }}
|
||||
signing-key-store-base64: ${{ secrets.SIGNING_KEY_STORE_BASE64 }}
|
||||
signing-key-alias: ${{ secrets.SIGNING_KEY_ALIAS }}
|
||||
signing-key-password: ${{ secrets.SIGNING_KEY_PASSWORD }}
|
||||
signing-store-password: ${{ secrets.SIGNING_STORE_PASSWORD }}
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-artifacts
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: insecure-artifacts
|
||||
- name: Create Github Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
generate_release_notes: true
|
||||
prerelease: true
|
||||
files: |
|
||||
./apk/release/app-release.apk
|
||||
./bundle/release/app-release.aab
|
||||
./apk/insecure/app-insecure.apk
|
||||
./bundle/insecure/app-insecure.aab
|
||||
-371
@@ -1,371 +0,0 @@
|
||||
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,macos,linux,intellij,androidstudio,android,dotenv
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,macos,linux,intellij,androidstudio,android,dotenv
|
||||
|
||||
### Android ###
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Log/OS Files
|
||||
*.log
|
||||
|
||||
# Android Studio generated files and folders
|
||||
captures/
|
||||
.externalNativeBuild/
|
||||
.cxx/
|
||||
*.apk
|
||||
output.json
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/
|
||||
misc.xml
|
||||
deploymentTargetDropDown.xml
|
||||
render.experimental.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
### Android Patch ###
|
||||
gen-external-apklibs
|
||||
|
||||
# Replacement of .externalNativeBuild directories introduced
|
||||
# with Android Studio 3.5.
|
||||
|
||||
### dotenv ###
|
||||
.env
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator-enh.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
.idea/$CACHE_FILE$
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
.idea/codestream.xml
|
||||
|
||||
# Azure Toolkit for IntelliJ plugin
|
||||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
||||
.idea/**/azureSettings.xml
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### macOS Patch ###
|
||||
# iCloud generated files
|
||||
*.icloud
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### AndroidStudio ###
|
||||
# Covers files to be ignored for android development using Android Studio.
|
||||
|
||||
# Built application files
|
||||
*.ap_
|
||||
*.aab
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
|
||||
# Gradle files
|
||||
.gradle
|
||||
|
||||
# Signing files
|
||||
.signing/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
|
||||
# Android Studio
|
||||
/*/build/
|
||||
/*/local.properties
|
||||
/*/out
|
||||
/*/*/build
|
||||
/*/*/production
|
||||
.navigation/
|
||||
*.ipr
|
||||
*.swp
|
||||
|
||||
# Keystore files
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
# google-services.json
|
||||
|
||||
# Android Patch
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
|
||||
# NDK
|
||||
obj/
|
||||
|
||||
# IntelliJ IDEA
|
||||
/out/
|
||||
|
||||
# User-specific configurations
|
||||
.idea/caches/
|
||||
.idea/libraries/
|
||||
.idea/shelf/
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/.name
|
||||
.idea/compiler.xml
|
||||
.idea/copyright/profiles_settings.xml
|
||||
.idea/encodings.xml
|
||||
.idea/misc.xml
|
||||
.idea/modules.xml
|
||||
.idea/scopes/scope_settings.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
.idea/datasources.xml
|
||||
.idea/dataSources.ids
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/gradle.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/navEditor.xml
|
||||
|
||||
# Legacy Eclipse project files
|
||||
.classpath
|
||||
.project
|
||||
.cproject
|
||||
.settings/
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
|
||||
hs_err_pid*
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
|
||||
# JIRA plugin
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
|
||||
### AndroidStudio Patch ###
|
||||
|
||||
!/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,macos,linux,intellij,androidstudio,android,dotenv
|
||||
|
||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,398 +0,0 @@
|
||||
<a name="readme-top"></a>
|
||||
<!--
|
||||
*** Thanks for checking out the Best-README-Template. If you have a suggestion
|
||||
*** that would make this better, please fork the repo and create a pull request
|
||||
*** or simply open an issue with the tag "enhancement".
|
||||
*** Don't forget to give the project a star!
|
||||
*** Thanks again! Now go create something AMAZING! :D
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<!-- PROJECT SHIELDS -->
|
||||
<!--
|
||||
*** I'm using markdown "reference style" links for readability.
|
||||
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
|
||||
*** See the bottom of this document for the declaration of the reference variables
|
||||
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
|
||||
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
|
||||
-->
|
||||
[![Contributors][contributors-shield]][contributors-url]
|
||||
[![Forks][forks-shield]][forks-url]
|
||||
[![Stargazers][stars-shield]][stars-url]
|
||||
[![Issues][issues-shield]][issues-url]
|
||||
[![Apache 2.0 License][license-shield]][license-url]
|
||||
|
||||
|
||||
|
||||
<!-- PROJECT LOGO -->
|
||||
<br />
|
||||
<div align="center">
|
||||
<a href="https://github.com/capcom6/android-sms-gateway">
|
||||
<img src="assets/logo.png" alt="Logo" width="80" height="80">
|
||||
</a>
|
||||
|
||||
<h3 align="center">SMS Gateway for Android™</h3>
|
||||
|
||||
<p align="center">
|
||||
Turns your smartphone into an SMS gateway for sending and receiving messages via API.
|
||||
<br />
|
||||
<a href="https://sms-gate.app"><strong>Explore the docs »</strong></a>
|
||||
<br />
|
||||
<br />
|
||||
<!-- <a href="https://github.com/capcom6/android-sms-gateway">View Demo</a> -->
|
||||
<a href="https://github.com/capcom6/android-sms-gateway/issues">Report Bug</a>
|
||||
·
|
||||
<a href="https://github.com/capcom6/android-sms-gateway/issues">Request Feature</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- TABLE OF CONTENTS -->
|
||||
- [About The Project](#about-the-project)
|
||||
- [Features](#features)
|
||||
- [Ideal For](#ideal-for)
|
||||
- [Built With](#built-with)
|
||||
- [Installation](#installation)
|
||||
- [Build Variants](#build-variants)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Permissions](#permissions)
|
||||
- [Installation from APK](#installation-from-apk)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Local Server](#local-server)
|
||||
- [Cloud Server](#cloud-server)
|
||||
- [Webhooks](#webhooks)
|
||||
- [Supported Events](#supported-events)
|
||||
- [Setting Up Webhooks](#setting-up-webhooks)
|
||||
- [Roadmap](#roadmap)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
- [Contact](#contact)
|
||||
- [Links](#links)
|
||||
|
||||
<!-- ABOUT THE PROJECT -->
|
||||
## About The Project
|
||||
|
||||
<p align="center"><img src="assets/screenshot.png" width="360"></p>
|
||||
|
||||
|
||||
SMS Gateway turns your Android smartphone into an SMS gateway. It's a lightweight application that allows you to send SMS messages programmatically via an API or CLI tool and receive webhooks on incoming SMS. This makes it ideal for integrating SMS functionality into your own applications or services.
|
||||
|
||||
### Features
|
||||
|
||||
📱 Core Functionality:
|
||||
|
||||
- 🆓 **No registration required:** No registration or email is required to create an account. In local mode, you don't need an account at all!
|
||||
- 📨 **Send and Receive SMS via API:** Use [our API](https://docs.sms-gate.app/integration/api/) to send messages directly from your applications or services.
|
||||
- 🤖 **Support for Android 5.0 and above:** Compatible with Android 5.0 and later versions. [See Android 15 Note](https://docs.sms-gate.app/faq/general/#does-the-app-support-android-15)
|
||||
|
||||
💬 Message Handling:
|
||||
|
||||
- 📜 **Multipart messages:** Send long messages with auto-partitioning.
|
||||
- 📊 **Message status tracking:** Monitor the status of sent messages in real-time.
|
||||
- 📥 **Incoming messages viewer:** View all received SMS, Data SMS, and MMS messages directly in the app with organized tabs and statistics.
|
||||
- 🔔 **Real-time incoming message notifications:** Receive instant SMS and MMS notifications via webhooks.
|
||||
- 📖 **Read received messages:** Access [previously received messages](https://docs.sms-gate.app/features/reading-messages/) via the same webhooks used for real-time notifications.
|
||||
- 📎 **MMS download notifications:** Receive webhook notifications when MMS messages are fully downloaded, including message body and attachments.
|
||||
|
||||
🔒 Security and Privacy:
|
||||
|
||||
- 🔐 **End-to-end encryption:** Encrypts message content and recipients' phone numbers before sending them to the API and decrypts them on the device.
|
||||
- 🏢 **Private server support:** Use a backend server in your own infrastructure for enhanced security.
|
||||
|
||||
🔧 Advanced Features:
|
||||
|
||||
- 💳 **Multiple SIM card support:** Supports devices with [multiple SIM cards](https://docs.sms-gate.app/features/multi-sim/).
|
||||
- 📱📱 **Multiple device support:** Connect [multiple devices](https://docs.sms-gate.app/features/multi-device/) to the same account with Cloud or Private server. Messages sent via the server are distributed across all connected devices.
|
||||
- 💾 **Data SMS support:** Send and receive binary [data payloads](https://docs.sms-gate.app/features/data-sms.md) via SMS for IoT commands, encrypted messages, and other specialized use cases.
|
||||
|
||||
🔌 Integration:
|
||||
|
||||
- 🪝 **Webhooks:** Set up [webhooks](https://docs.sms-gate.app/features/webhooks/) to be triggered on specified events.
|
||||
|
||||
### Ideal For
|
||||
|
||||
- 🔐 **Authentication & Verification:** Secure user accounts and transactions with SMS-based two-factor authentication, minimizing the risk of unauthorized access.
|
||||
- 📩 **Transactional Messages:** Send confirmation messages for user actions, enhancing the reliability and perception of your brand.
|
||||
- ⏰ **SMS Reminders:** Prompt users about upcoming events or appointments to ensure engagement and reduce missed opportunities.
|
||||
- 🔔 **SMS Notifications:** Deliver immediate notifications to users for important updates, offers, and service enhancements.
|
||||
- 📊 **User Feedback:** Solicit and collect user feedback through SMS, providing valuable insights for improving your services.
|
||||
|
||||
*Note*: It is not recommended to use this for batch sending due to potential mobile operator restrictions.
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
|
||||
|
||||
### Built With
|
||||
|
||||
- [](https://kotlinlang.org/)
|
||||
- [](https://ktor.io/)
|
||||
- [](https://developer.android.com/training/data-storage/room)
|
||||
- [](https://firebase.google.com/)
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
## Installation
|
||||
|
||||
You can install app to your device from [prebuilt APK](https://github.com/capcom6/android-sms-gateway/releases).
|
||||
|
||||
### Build Variants
|
||||
|
||||
The project provides two pre-built variants:
|
||||
|
||||
- **Secure (release) build**: Production-ready with strict security configurations. This is the recommended build for production deployments.
|
||||
- **Insecure build**: For development and testing with cleartext traffic allowed. **This build should never be used in public environments.**
|
||||
|
||||
### Prerequisites
|
||||
|
||||
You need an Android device with Android 5.0 (Lollipop) or above for using the application.
|
||||
|
||||
#### Permissions
|
||||
|
||||
To use the application, you need to grant the following permissions:
|
||||
|
||||
- **SEND_SMS**: This permission is required to send SMS messages.
|
||||
- **READ_PHONE_STATE**: This permission is optional. If you want to select the SIM card, you can grant this permission.
|
||||
- **READ_SMS**: This permission is optional. If you want to read previous SMS messages, you need to grant this permission.
|
||||
- **RECEIVE_SMS**: This permission is optional. If you want to receive webhooks on incoming SMS, you need to grant this permission.
|
||||
- **RECEIVE_MMS**, **RECEIVE_WAP_PUSH**: This permissions are optional. If you want to receive webhooks on incoming MMS messages, you need to grant these permissions.
|
||||
|
||||
### Installation from APK
|
||||
|
||||
1. Navigate to the [Releases](https://github.com/capcom6/android-sms-gateway/releases) page.
|
||||
2. Download the latest APK file from the list of available releases.
|
||||
3. Transfer the APK file to your Android device.
|
||||
4. On your Android device, go to **Settings** > **Security** (or **Privacy** on some devices).
|
||||
5. Enable the **Unknown sources** option to allow installation of apps from sources other than the Play Store.
|
||||
6. Use a file manager app to navigate to the location of the downloaded APK file.
|
||||
7. Tap on the APK file to start the installation process.
|
||||
8. Follow the on-screen prompts to complete the installation.
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
<!-- GETTING STARTED -->
|
||||
## Getting Started
|
||||
|
||||
_For integration examples, please refer to the [CLI Tool Documentation](https://sms-gate.app/integration/cli/) and [API Documentation](https://sms-gate.app/integration/api/)_
|
||||
|
||||
The SMS Gateway for Android can work in two modes: with a Local Server started on the device or with a Cloud Server. The basic API is the same for both modes and is documented on the [SMS Gateway for Android API Documentation](https://capcom6.github.io/android-sms-gateway/) page.
|
||||
|
||||
### Local Server
|
||||
|
||||
<div align="center">
|
||||
<img src="/assets/local-server.png" alt="Local server example settings">
|
||||
</div>
|
||||
|
||||
This mode is ideal for sending messages from a local network.
|
||||
|
||||
1. Launch the app on your device.
|
||||
2. Toggle the `Local Server` switch to the "on" position.
|
||||
3. Tap the `Offline` button at the bottom of the screen to activate the server.
|
||||
4. In the `Local Server` section, your device's local and public IP addresses will be displayed, along with the credentials for basic authentication. Note that the public IP address is only accessible if you have a public (or "white") IP and your firewall is configured correctly.
|
||||
5. To send a message from within the local network, execute a `curl` command like the one below. Replace `<username>`, `<password>`, and `<device_local_ip>` with the actual values provided in the previous step:
|
||||
|
||||
```sh
|
||||
curl -X POST -u <username>:<password> \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{ "textMessage": { "text": "Hello, doctors!" }, "phoneNumbers": ["+19162255887", "+19162255888"] }' \
|
||||
http://<device_local_ip>:8080/message
|
||||
```
|
||||
|
||||
Alternatively, you can use the CLI Tool:
|
||||
|
||||
```sh
|
||||
smsgate -e 'http://<device_local_ip>:8080/message' -u <username> -p <password> \
|
||||
send --phones '+19162255887,+19162255888' 'Hello, doctors!'
|
||||
```
|
||||
|
||||
### Cloud Server
|
||||
|
||||
<div align="center">
|
||||
<img src="/assets/cloud-server.png" alt="Cloud server example settings">
|
||||
</div>
|
||||
|
||||
Use the cloud server mode when dealing with dynamic or shared device IP addresses.
|
||||
|
||||
1. Launch the app on your device.
|
||||
2. Toggle the `Cloud Server` switch to the "on" position.
|
||||
3. Tap the `Online` button located at the bottom of the screen to connect to the cloud server.
|
||||
4. In the `Cloud Server` section, the credentials for basic authentication will be displayed.
|
||||
5. To send a message via the cloud server, perform a `curl` request with a command similar to the following, substituting `<username>` and `<password>` with the actual values obtained in step 4:
|
||||
|
||||
```sh
|
||||
curl -X POST -u <username>:<password> \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{ "textMessage": { "text": "Hello, doctors!" }, "phoneNumbers": ["+19162255887", "+19162255888"] }' \
|
||||
https://api.sms-gate.app/3rdparty/v1/message
|
||||
```
|
||||
|
||||
Or with CLI:
|
||||
|
||||
```sh
|
||||
smsgate -u <username> -p <password> \
|
||||
send --phones '+19162255887,+19162255888' 'Hello, doctors!'
|
||||
```
|
||||
|
||||
For further privacy, you can deploy your own private server. See the [Private Server](https://sms-gate.app/getting-started/private-server/) section for more details.
|
||||
|
||||
### Webhooks
|
||||
|
||||
Use webhooks to receive notifications for messaging events (e.g., incoming SMS and MMS).
|
||||
|
||||
#### Supported Events
|
||||
|
||||
| Event | Description |
|
||||
| ------------------- | --------------------------------------------------------------------------- |
|
||||
| `sms:received` | Triggered when an SMS message is received |
|
||||
| `sms:sent` | Triggered when an SMS message is sent |
|
||||
| `sms:delivered` | Triggered when an SMS message is delivered |
|
||||
| `sms:failed` | Triggered when an SMS message fails to send |
|
||||
| `sms:data-received` | Triggered when a data SMS is received |
|
||||
| `mms:received` | Triggered when an MMS notification is received (before download) |
|
||||
| `mms:downloaded` | Triggered when an MMS message is fully downloaded with body and attachments |
|
||||
| `system:ping` | Periodic heartbeat event |
|
||||
|
||||
#### Setting Up Webhooks
|
||||
|
||||
Follow these steps to set up webhooks:
|
||||
|
||||
1. Set up your own HTTP server with a valid SSL certificate to receive webhooks. For testing purposes, [webhook.site](https://webhook.site) can be useful.
|
||||
2. Register your webhook with an API request:
|
||||
|
||||
```sh
|
||||
curl -X POST -u <username>:<password> \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{ "id": "unique-id", "url": "https://webhook.site/<your-uuid>", "event": "sms:received" }' \
|
||||
http://<device_local_ip>:8080/webhooks
|
||||
```
|
||||
3. Send an SMS to the device.
|
||||
4. The application will dispatch POST request to the specified URL with a payload such as:
|
||||
|
||||
```json
|
||||
{
|
||||
"event": "sms:received",
|
||||
"payload": {
|
||||
"messageId": "msg_12345abcde",
|
||||
"message": "Received SMS text",
|
||||
"phoneNumber": "+19162255887",
|
||||
"simNumber": 1,
|
||||
"receivedAt": "2024-06-07T11:41:31.000+07:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
5. To deregister a webhook, execute a `curl` request using the following pattern:
|
||||
|
||||
```sh
|
||||
curl -X DELETE -u <username>:<password> \
|
||||
http://<device_local_ip>:8080/webhooks/unique-id
|
||||
```
|
||||
|
||||
For cloud mode the process is similar, simply change the URL to https://api.sms-gate.app/3rdparty/v1/webhooks. Webhooks in Local and Cloud mode are independent.
|
||||
|
||||
*Note*: Webhooks are transmitted directly from the device; therefore, the device must have an outgoing internet connection. As the requests originate from the device, incoming messages remain inaccessible to us.
|
||||
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
|
||||
|
||||
<!-- ROADMAP -->
|
||||
## Roadmap
|
||||
|
||||
- [x] Add functionality to modify user credentials.
|
||||
- [x] Introduce option to adjust the local server port.
|
||||
- [x] Send notifications to an external server when the status of a message changes.
|
||||
- [ ] Incorporate scheduling capabilities for dispatching messages at specific times.
|
||||
- [ ] Implement region-based restrictions to prevent international SMS.
|
||||
- [ ] Provide an API endpoint to retrieve the list of available SIM cards on the device.
|
||||
- [x] Include detailed error messages in responses and logs.
|
||||
|
||||
See the [open issues](https://github.com/capcom6/android-sms-gateway/issues) for a full list of proposed features (and known issues).
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
|
||||
|
||||
<!-- CONTRIBUTING -->
|
||||
## Contributing
|
||||
|
||||
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
||||
|
||||
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
|
||||
Don't forget to give the project a star! Thanks again!
|
||||
|
||||
1. Fork the Project
|
||||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
||||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
||||
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
||||
5. Open a Pull Request
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
|
||||
|
||||
<!-- LICENSE -->
|
||||
## License
|
||||
|
||||
Distributed under the Apache-2.0 license. See [LICENSE](LICENSE) for more information.
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
|
||||
|
||||
<!-- CONTACT -->
|
||||
## Contact
|
||||
|
||||
If you have any questions or suggestions, feel free to reach out through the following channels:
|
||||
|
||||
- **Issue Tracker:** [https://github.com/capcom6/android-sms-gateway/issues](https://github.com/capcom6/android-sms-gateway/issues)
|
||||
- **Email:** [support@sms-gate.app](mailto:support@sms-gate.app)
|
||||
- **Discord:** [Join our Discord server](https://discord.gg/vv9raFK4gX)
|
||||
|
||||
### Links
|
||||
|
||||
- **Website:** [https://sms-gate.app](https://sms-gate.app)
|
||||
- **Documentation:** [https://docs.sms-gate.app](https://docs.sms-gate.app)
|
||||
- **Status Page:** [https://status.sms-gate.app](https://status.sms-gate.app)
|
||||
- **Project:** [https://github.com/android-sms-gateway](https://github.com/android-sms-gateway)
|
||||
- **Main Repository:** [https://github.com/capcom6/android-sms-gateway](https://github.com/capcom6/android-sms-gateway)
|
||||
- **Author GitHub:** [capcom6](https://github.com/capcom6)
|
||||
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
|
||||
|
||||
<!-- ACKNOWLEDGMENTS -->
|
||||
<!-- ## Acknowledgments
|
||||
|
||||
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!
|
||||
|
||||
* [Choose an Open Source License](https://choosealicense.com)
|
||||
* [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet)
|
||||
* [Malven's Flexbox Cheatsheet](https://flexbox.malven.co/)
|
||||
* [Malven's Grid Cheatsheet](https://grid.malven.co/)
|
||||
* [Img Shields](https://shields.io)
|
||||
* [GitHub Pages](https://pages.github.com)
|
||||
* [Font Awesome](https://fontawesome.com)
|
||||
* [React Icons](https://react-icons.github.io/react-icons/search)
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p> -->
|
||||
|
||||
|
||||
|
||||
<!-- MARKDOWN LINKS & IMAGES -->
|
||||
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
||||
[contributors-shield]: https://img.shields.io/github/contributors/capcom6/android-sms-gateway.svg?style=for-the-badge
|
||||
[contributors-url]: https://github.com/capcom6/android-sms-gateway/graphs/contributors
|
||||
[forks-shield]: https://img.shields.io/github/forks/capcom6/android-sms-gateway.svg?style=for-the-badge
|
||||
[forks-url]: https://github.com/capcom6/android-sms-gateway/network/members
|
||||
[stars-shield]: https://img.shields.io/github/stars/capcom6/android-sms-gateway.svg?style=for-the-badge
|
||||
[stars-url]: https://github.com/capcom6/android-sms-gateway/stargazers
|
||||
[issues-shield]: https://img.shields.io/github/issues/capcom6/android-sms-gateway.svg?style=for-the-badge
|
||||
[issues-url]: https://github.com/capcom6/android-sms-gateway/issues
|
||||
[license-shield]: https://img.shields.io/github/license/capcom6/android-sms-gateway.svg?style=for-the-badge
|
||||
[license-url]: https://github.com/capcom6/android-sms-gateway/blob/master/LICENSE
|
||||
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,136 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.google.gms.google-services'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "pt.whatsms.gateway"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 11
|
||||
versionName "3.1.0-hardcode"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("keystore.jks")
|
||||
storePassword System.getenv("SIGNING_STORE_PASSWORD")
|
||||
keyAlias System.getenv("SIGNING_KEY_ALIAS")
|
||||
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config"]
|
||||
}
|
||||
debugInsecure {
|
||||
debuggable true
|
||||
manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config_insecure"]
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
insecure {
|
||||
initWith debug
|
||||
debuggable true
|
||||
signingConfig signingConfigs.release
|
||||
manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config_insecure"]
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
manifestPlaceholders = [networkSecurityConfig: "@xml/network_security_config"]
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/INDEX.LIST'
|
||||
exclude 'META-INF/io.netty.versions.properties'
|
||||
}
|
||||
namespace 'me.capcom.smsgateway'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def ktor_version = "2.2.4"
|
||||
def okhttp_version = "4.10.0"
|
||||
def room_version = "2.4.3"
|
||||
def coroutines_version = "1.6.1"
|
||||
def work_version = "2.7.1"
|
||||
def koin_version = "3.4.0"
|
||||
def lifecycle_version = "2.6.2"
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
|
||||
|
||||
implementation("io.ktor:ktor-serialization-gson:$ktor_version")
|
||||
|
||||
implementation("io.ktor:ktor-server-core:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-netty:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-compression:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-status-pages:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-content-negotiation:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-call-logging:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-auth:$ktor_version")
|
||||
implementation("io.ktor:ktor-server-auth-jwt:$ktor_version")
|
||||
|
||||
implementation("io.ktor:ktor-client-core:$ktor_version")
|
||||
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
|
||||
implementation("io.ktor:ktor-client-okhttp:$ktor_version")
|
||||
|
||||
implementation("com.squareup.okhttp3:okhttp:$okhttp_version")
|
||||
implementation("com.squareup.okhttp3:okhttp-sse:$okhttp_version")
|
||||
|
||||
// Kotlin + coroutines
|
||||
implementation "androidx.work:work-runtime-ktx:$work_version"
|
||||
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
|
||||
|
||||
implementation("androidx.preference:preference-ktx:1.2.0")
|
||||
|
||||
implementation("androidx.core:core-ktx:1.8.0")
|
||||
implementation("androidx.appcompat:appcompat:1.4.2")
|
||||
implementation("com.google.android.material:material:1.6.1")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||
|
||||
implementation("com.aventrix.jnanoid:jnanoid:2.0.0")
|
||||
|
||||
implementation("androidx.room:room-ktx:$room_version")
|
||||
annotationProcessor("androidx.room:room-compiler:$room_version")
|
||||
kapt("androidx.room:room-compiler:$room_version")
|
||||
|
||||
// Import the Firebase BoM
|
||||
implementation platform('com.google.firebase:firebase-bom:31.1.1')
|
||||
implementation 'com.google.firebase:firebase-messaging-ktx'
|
||||
|
||||
implementation 'com.googlecode.libphonenumber:libphonenumber:9.0.22'
|
||||
|
||||
// Koin for Android
|
||||
implementation "io.insert-koin:koin-android:$koin_version"
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.3")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "me.capcom.smsgateway",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0.0",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "67fe481b485f4d2705ab746884ad69b1",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `state` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '67fe481b485f4d2705ab746884ad69b1')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 10,
|
||||
"identityHash": "76eadaecfb0d5b84f7038edff0d0a1cf",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_processedAt` ON `${TABLE_NAME}` (`processedAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '76eadaecfb0d5b84f7038edff0d0a1cf')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 11,
|
||||
"identityHash": "8d650175dcd787e41529e8a5c6327311",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_processedAt` ON `${TABLE_NAME}` (`processedAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8d650175dcd787e41529e8a5c6327311')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,366 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 12,
|
||||
"identityHash": "0bb7c2a525bfb354699c9acfec6fb7a1",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_processedAt` ON `${TABLE_NAME}` (`processedAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0bb7c2a525bfb354699c9acfec6fb7a1')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,382 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 13,
|
||||
"identityHash": "1ef93309ad8e6da02819b46ed75fc050",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `priority` INTEGER NOT NULL DEFAULT 0, `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_state",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state` ON `${TABLE_NAME}` (`state`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_processedAt` ON `${TABLE_NAME}` (`processedAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1ef93309ad8e6da02819b46ed75fc050')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,389 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 14,
|
||||
"identityHash": "b6d02f75a658aca5ece43d2a914dba57",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_state",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state` ON `${TABLE_NAME}` (`state`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_processedAt` ON `${TABLE_NAME}` (`processedAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'b6d02f75a658aca5ece43d2a914dba57')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 15,
|
||||
"identityHash": "e94488261a9a62360b4540f737805373",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_processedAt` ON `${TABLE_NAME}` (`state`, `processedAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_createdAt` ON `${TABLE_NAME}` (`state`, `createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e94488261a9a62360b4540f737805373')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,397 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 16,
|
||||
"identityHash": "c9bca869f0cb40b9f25fbc44308fe786",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `partsCount` INTEGER, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "partsCount",
|
||||
"columnName": "partsCount",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_processedAt` ON `${TABLE_NAME}` (`state`, `processedAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_createdAt` ON `${TABLE_NAME}` (`state`, `createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c9bca869f0cb40b9f25fbc44308fe786')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,482 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 17,
|
||||
"identityHash": "e647a679fe74540d36be13c53eadc9cb",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `partsCount` INTEGER, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "partsCount",
|
||||
"columnName": "partsCount",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_processedAt` ON `${TABLE_NAME}` (`state`, `processedAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_createdAt` ON `${TABLE_NAME}` (`state`, `createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "webhook_queue",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL, `payload` TEXT NOT NULL, `retry_count` INTEGER NOT NULL DEFAULT 0, `status` TEXT NOT NULL DEFAULT 'pending', `created_at` INTEGER NOT NULL, `next_attempt` INTEGER NOT NULL, `last_error` TEXT)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "payload",
|
||||
"columnName": "payload",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "retryCount",
|
||||
"columnName": "retry_count",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "status",
|
||||
"columnName": "status",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'pending'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "created_at",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "nextAttempt",
|
||||
"columnName": "next_attempt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "lastError",
|
||||
"columnName": "last_error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_webhook_queue_status_next_attempt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"next_attempt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_next_attempt` ON `${TABLE_NAME}` (`status`, `next_attempt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_webhook_queue_status_created_at",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"created_at"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_created_at` ON `${TABLE_NAME}` (`status`, `created_at`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e647a679fe74540d36be13c53eadc9cb')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,524 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 18,
|
||||
"identityHash": "b001a953ad105f209e7c4a05c2f4c3ff",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `partsCount` INTEGER, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "partsCount",
|
||||
"columnName": "partsCount",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_processedAt` ON `${TABLE_NAME}` (`state`, `processedAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_createdAt` ON `${TABLE_NAME}` (`state`, `createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "webhook_queue",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL, `payload` TEXT NOT NULL, `retry_count` INTEGER NOT NULL DEFAULT 0, `status` TEXT NOT NULL DEFAULT 'pending', `created_at` INTEGER NOT NULL, `next_attempt` INTEGER NOT NULL, `last_error` TEXT)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "payload",
|
||||
"columnName": "payload",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "retryCount",
|
||||
"columnName": "retry_count",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "status",
|
||||
"columnName": "status",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'pending'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "created_at",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "nextAttempt",
|
||||
"columnName": "next_attempt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "lastError",
|
||||
"columnName": "last_error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_webhook_queue_status_next_attempt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"next_attempt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_next_attempt` ON `${TABLE_NAME}` (`status`, `next_attempt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_webhook_queue_status_created_at",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"created_at"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_created_at` ON `${TABLE_NAME}` (`status`, `created_at`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "tokens",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `expiresAt` INTEGER NOT NULL, `revokedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "expiresAt",
|
||||
"columnName": "expiresAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "revokedAt",
|
||||
"columnName": "revokedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_tokens_expiresAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"expiresAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_tokens_expiresAt` ON `${TABLE_NAME}` (`expiresAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'b001a953ad105f209e7c4a05c2f4c3ff')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,605 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 19,
|
||||
"identityHash": "ea9afd972e8ac233d6efa55d7cc8109b",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `partsCount` INTEGER, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "partsCount",
|
||||
"columnName": "partsCount",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_processedAt` ON `${TABLE_NAME}` (`state`, `processedAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_createdAt` ON `${TABLE_NAME}` (`state`, `createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "webhook_queue",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL, `payload` TEXT NOT NULL, `retry_count` INTEGER NOT NULL DEFAULT 0, `status` TEXT NOT NULL DEFAULT 'pending', `created_at` INTEGER NOT NULL, `next_attempt` INTEGER NOT NULL, `last_error` TEXT)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "payload",
|
||||
"columnName": "payload",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "retryCount",
|
||||
"columnName": "retry_count",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "status",
|
||||
"columnName": "status",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'pending'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "created_at",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "nextAttempt",
|
||||
"columnName": "next_attempt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "lastError",
|
||||
"columnName": "last_error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_webhook_queue_status_next_attempt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"next_attempt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_next_attempt` ON `${TABLE_NAME}` (`status`, `next_attempt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_webhook_queue_status_created_at",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"created_at"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_created_at` ON `${TABLE_NAME}` (`status`, `created_at`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "tokens",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `expiresAt` INTEGER NOT NULL, `revokedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "expiresAt",
|
||||
"columnName": "expiresAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "revokedAt",
|
||||
"columnName": "revokedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_tokens_expiresAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"expiresAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_tokens_expiresAt` ON `${TABLE_NAME}` (`expiresAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "incoming_messages",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `type` TEXT NOT NULL, `sender` TEXT NOT NULL, `recipient` TEXT, `simNumber` INTEGER, `subscriptionId` INTEGER, `contentPreview` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "sender",
|
||||
"columnName": "sender",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "recipient",
|
||||
"columnName": "recipient",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "subscriptionId",
|
||||
"columnName": "subscriptionId",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "contentPreview",
|
||||
"columnName": "contentPreview",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_incoming_messages_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_incoming_messages_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_incoming_messages_type",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"type"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_incoming_messages_type` ON `${TABLE_NAME}` (`type`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ea9afd972e8ac233d6efa55d7cc8109b')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 2,
|
||||
"identityHash": "1c3c3246ea0f368ec95b740b2f50e18b",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1c3c3246ea0f368ec95b740b2f50e18b')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,605 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 20,
|
||||
"identityHash": "b746d44a36cc274b009e421faa9c96ee",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `priority` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `type` TEXT NOT NULL DEFAULT 'Text', `content` TEXT NOT NULL, `state` TEXT NOT NULL, `partsCount` INTEGER, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Text'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "content",
|
||||
"columnName": "content",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "partsCount",
|
||||
"columnName": "partsCount",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_processedAt` ON `${TABLE_NAME}` (`state`, `processedAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_state_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"state",
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_state_createdAt` ON `${TABLE_NAME}` (`state`, `createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "RecipientState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`, `state`), FOREIGN KEY(`messageId`, `phoneNumber`) REFERENCES `MessageRecipient`(`messageId`, `phoneNumber`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "MessageRecipient",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "MessageState",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `state` TEXT NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`messageId`, `state`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "updatedAt",
|
||||
"columnName": "updatedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"state"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "WebHook",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `event` TEXT NOT NULL, `source` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "event",
|
||||
"columnName": "event",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "webhook_queue",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `url` TEXT NOT NULL, `payload` TEXT NOT NULL, `retry_count` INTEGER NOT NULL DEFAULT 0, `status` TEXT NOT NULL DEFAULT 'pending', `created_at` INTEGER NOT NULL, `next_attempt` INTEGER NOT NULL, `last_error` TEXT, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "payload",
|
||||
"columnName": "payload",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "retryCount",
|
||||
"columnName": "retry_count",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "status",
|
||||
"columnName": "status",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'pending'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "created_at",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "nextAttempt",
|
||||
"columnName": "next_attempt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "lastError",
|
||||
"columnName": "last_error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_webhook_queue_status_next_attempt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"next_attempt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_next_attempt` ON `${TABLE_NAME}` (`status`, `next_attempt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_webhook_queue_status_created_at",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"status",
|
||||
"created_at"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_webhook_queue_status_created_at` ON `${TABLE_NAME}` (`status`, `created_at`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "logs_entries",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`priority` TEXT NOT NULL, `module` TEXT NOT NULL, `message` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `context` TEXT, `createdAt` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "priority",
|
||||
"columnName": "priority",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "module",
|
||||
"columnName": "module",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "context",
|
||||
"columnName": "context",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": true
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_logs_entries_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_logs_entries_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "tokens",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `expiresAt` INTEGER NOT NULL, `revokedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "expiresAt",
|
||||
"columnName": "expiresAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "revokedAt",
|
||||
"columnName": "revokedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_tokens_expiresAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"expiresAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_tokens_expiresAt` ON `${TABLE_NAME}` (`expiresAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "incoming_messages",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `type` TEXT NOT NULL, `sender` TEXT NOT NULL, `recipient` TEXT, `simNumber` INTEGER, `subscriptionId` INTEGER, `contentPreview` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "sender",
|
||||
"columnName": "sender",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "recipient",
|
||||
"columnName": "recipient",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "subscriptionId",
|
||||
"columnName": "subscriptionId",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "contentPreview",
|
||||
"columnName": "contentPreview",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_incoming_messages_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_incoming_messages_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_incoming_messages_type",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"type"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_incoming_messages_type` ON `${TABLE_NAME}` (`type`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'b746d44a36cc274b009e421faa9c96ee')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 3,
|
||||
"identityHash": "89b4d1142a9c77effbb234879f4b540a",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '89b4d1142a9c77effbb234879f4b540a')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 4,
|
||||
"identityHash": "e4a0450ae2b806b52bfbcd2456501a1d",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e4a0450ae2b806b52bfbcd2456501a1d')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 5,
|
||||
"identityHash": "4a86263b9bb6a736271cc66c6faca254",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `createdAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '4a86263b9bb6a736271cc66c6faca254')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 6,
|
||||
"identityHash": "c85c71171bb3e9eb347615dd91e7ae82",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `state` TEXT NOT NULL, `source` TEXT NOT NULL DEFAULT 'Local', `createdAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c85c71171bb3e9eb347615dd91e7ae82')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 7,
|
||||
"identityHash": "0638620d8ed8717433cb8e718cfc4646",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0638620d8ed8717433cb8e718cfc4646')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 8,
|
||||
"identityHash": "0638620d8ed8717433cb8e718cfc4646",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0638620d8ed8717433cb8e718cfc4646')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 9,
|
||||
"identityHash": "bfb73410aeb4903b9ea559c1b60bd8e3",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "Message",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `text` TEXT NOT NULL, `withDeliveryReport` INTEGER NOT NULL DEFAULT 1, `simNumber` INTEGER, `validUntil` TEXT, `isEncrypted` INTEGER NOT NULL DEFAULT 0, `skipPhoneValidation` INTEGER NOT NULL DEFAULT 0, `source` TEXT NOT NULL DEFAULT 'Local', `state` TEXT NOT NULL, `createdAt` INTEGER NOT NULL DEFAULT 0, `processedAt` INTEGER, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "text",
|
||||
"columnName": "text",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "withDeliveryReport",
|
||||
"columnName": "withDeliveryReport",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "1"
|
||||
},
|
||||
{
|
||||
"fieldPath": "simNumber",
|
||||
"columnName": "simNumber",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "validUntil",
|
||||
"columnName": "validUntil",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "isEncrypted",
|
||||
"columnName": "isEncrypted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "skipPhoneValidation",
|
||||
"columnName": "skipPhoneValidation",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "source",
|
||||
"columnName": "source",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true,
|
||||
"defaultValue": "'Local'"
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "createdAt",
|
||||
"columnName": "createdAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true,
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"fieldPath": "processedAt",
|
||||
"columnName": "processedAt",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_Message_createdAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"createdAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_createdAt` ON `${TABLE_NAME}` (`createdAt`)"
|
||||
},
|
||||
{
|
||||
"name": "index_Message_processedAt",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"processedAt"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_Message_processedAt` ON `${TABLE_NAME}` (`processedAt`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "MessageRecipient",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`messageId` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `state` TEXT NOT NULL, `error` TEXT, PRIMARY KEY(`messageId`, `phoneNumber`), FOREIGN KEY(`messageId`) REFERENCES `Message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "messageId",
|
||||
"columnName": "messageId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "phoneNumber",
|
||||
"columnName": "phoneNumber",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "state",
|
||||
"columnName": "state",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "error",
|
||||
"columnName": "error",
|
||||
"affinity": "TEXT",
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"messageId",
|
||||
"phoneNumber"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "Message",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"messageId"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bfb73410aeb4903b9ea559c1b60bd8e3')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.capcom.smsgateway
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("me.capcom.smsgateway", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_SMS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_MMS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="${networkSecurityConfig}"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.SmsGateway">
|
||||
<service
|
||||
android:name=".modules.gateway.services.SSEForegroundService"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service
|
||||
android:name=".modules.ping.services.PingForegroundService"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
|
||||
<service
|
||||
android:name=".services.PushService"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
android:name=".receivers.EventsReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="me.capcom.smsgateway.ACTION_SENT" />
|
||||
<action android:name="me.capcom.smsgateway.ACTION_DELIVERED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name=".receivers.BootReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.ACTION_BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.REBOOT" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".modules.localserver.WebService"
|
||||
android:enabled="true"
|
||||
android:foregroundServiceType="connectedDevice" />
|
||||
<service
|
||||
android:name="androidx.work.impl.foreground.SystemForegroundService"
|
||||
android:foregroundServiceType="dataSync"
|
||||
tools:node="merge" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 141 KiB |
@@ -1,75 +0,0 @@
|
||||
package me.capcom.smsgateway
|
||||
|
||||
import android.app.Application
|
||||
import healthModule
|
||||
import me.capcom.smsgateway.data.dbModule
|
||||
import me.capcom.smsgateway.modules.connection.connectionModule
|
||||
import me.capcom.smsgateway.modules.encryption.encryptionModule
|
||||
import me.capcom.smsgateway.modules.events.eventBusModule
|
||||
import me.capcom.smsgateway.modules.gateway.GatewayService
|
||||
import me.capcom.smsgateway.modules.incoming.incomingModule
|
||||
import me.capcom.smsgateway.modules.localserver.localserverModule
|
||||
import me.capcom.smsgateway.modules.logs.logsModule
|
||||
import me.capcom.smsgateway.modules.messages.messagesModule
|
||||
import me.capcom.smsgateway.modules.notifications.notificationsModule
|
||||
import me.capcom.smsgateway.modules.orchestrator.OrchestratorService
|
||||
import me.capcom.smsgateway.modules.orchestrator.orchestratorModule
|
||||
import me.capcom.smsgateway.modules.ping.pingModule
|
||||
import me.capcom.smsgateway.modules.receiver.receiverModule
|
||||
import me.capcom.smsgateway.modules.settings.settingsModule
|
||||
import me.capcom.smsgateway.modules.webhooks.webhooksModule
|
||||
import me.capcom.smsgateway.receivers.EventsReceiver
|
||||
import org.koin.android.ext.android.get
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.core.context.startKoin
|
||||
|
||||
class App: Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
startKoin {
|
||||
androidLogger()
|
||||
androidContext(this@App)
|
||||
modules(
|
||||
eventBusModule,
|
||||
settingsModule,
|
||||
dbModule,
|
||||
logsModule,
|
||||
notificationsModule,
|
||||
messagesModule,
|
||||
incomingModule,
|
||||
receiverModule,
|
||||
encryptionModule,
|
||||
me.capcom.smsgateway.modules.gateway.gatewayModule,
|
||||
healthModule,
|
||||
webhooksModule,
|
||||
localserverModule,
|
||||
pingModule,
|
||||
connectionModule,
|
||||
orchestratorModule,
|
||||
)
|
||||
}
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(
|
||||
GlobalExceptionHandler(
|
||||
Thread.getDefaultUncaughtExceptionHandler()!!,
|
||||
get()
|
||||
)
|
||||
)
|
||||
|
||||
instance = this
|
||||
|
||||
EventsReceiver.register(this)
|
||||
|
||||
get<OrchestratorService>().start(this, true)
|
||||
}
|
||||
|
||||
val gatewayService: GatewayService by inject()
|
||||
|
||||
companion object {
|
||||
lateinit var instance: App
|
||||
private set
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package me.capcom.smsgateway
|
||||
|
||||
import android.util.Log
|
||||
import me.capcom.smsgateway.modules.logs.LogsService
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntry
|
||||
import org.koin.core.component.KoinComponent
|
||||
import java.lang.Thread.UncaughtExceptionHandler
|
||||
|
||||
class GlobalExceptionHandler(
|
||||
private val defaultHandler: UncaughtExceptionHandler,
|
||||
private val logger: LogsService
|
||||
) : UncaughtExceptionHandler, KoinComponent {
|
||||
|
||||
override fun uncaughtException(thread: Thread, throwable: Throwable) {
|
||||
try {
|
||||
logger.insert(
|
||||
LogEntry.Priority.ERROR,
|
||||
"GlobalExceptionHandler",
|
||||
"Unhandled exception in ${thread.name}",
|
||||
mapOf(
|
||||
"message" to throwable.message,
|
||||
"stackTrace" to throwable.stackTrace.joinToString("\n"),
|
||||
"threadName" to thread.name,
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("GlobalExceptionHandler", "Failed to log uncaught exception", e)
|
||||
} finally {
|
||||
defaultHandler.uncaughtException(thread, throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package me.capcom.smsgateway
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import me.capcom.smsgateway.databinding.ActivityMainBinding
|
||||
import me.capcom.smsgateway.ui.HolderFragment
|
||||
import me.capcom.smsgateway.ui.HomeFragment
|
||||
import me.capcom.smsgateway.ui.SettingsFragment
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val adapter = FragmentsAdapter(this)
|
||||
binding.viewPager.adapter = adapter
|
||||
|
||||
TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
|
||||
when (position) {
|
||||
0 -> tab.apply {
|
||||
text = getString(R.string.tab_text_home)
|
||||
setIcon(R.drawable.ic_home)
|
||||
}
|
||||
|
||||
1 -> tab.apply {
|
||||
text = getString(R.string.tab_text_messages)
|
||||
setIcon(R.drawable.ic_sms)
|
||||
}
|
||||
|
||||
2 -> tab.apply {
|
||||
text = getString(R.string.tab_text_settings)
|
||||
setIcon(R.drawable.ic_advanced)
|
||||
}
|
||||
}
|
||||
}.attach()
|
||||
|
||||
processIntent(intent)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
processIntent(intent)
|
||||
}
|
||||
|
||||
private fun processIntent(intent: Intent) {
|
||||
val tabIndex = intent.getIntExtra(EXTRA_TAB_INDEX, TAB_INDEX_HOME)
|
||||
|
||||
binding.viewPager.currentItem = tabIndex
|
||||
}
|
||||
|
||||
class FragmentsAdapter(activity: AppCompatActivity) :
|
||||
androidx.viewpager2.adapter.FragmentStateAdapter(activity) {
|
||||
|
||||
override fun getItemCount(): Int = 3
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return when (position) {
|
||||
0 -> HomeFragment.newInstance()
|
||||
1 -> HolderFragment.newInstance()
|
||||
else -> SettingsFragment.newInstance()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAB_INDEX_HOME = 0
|
||||
const val TAB_INDEX_MESSAGES = 1
|
||||
const val TAB_INDEX_SETTINGS = 2
|
||||
|
||||
private const val EXTRA_TAB_INDEX = "tabIndex"
|
||||
|
||||
fun starter(context: Context, tabIndex: Int): Intent {
|
||||
return Intent(context, MainActivity::class.java).apply {
|
||||
putExtra(EXTRA_TAB_INDEX, tabIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package me.capcom.smsgateway.data
|
||||
|
||||
import androidx.room.AutoMigration
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import me.capcom.smsgateway.data.dao.MessagesDao
|
||||
import me.capcom.smsgateway.data.dao.TokensDao
|
||||
import me.capcom.smsgateway.data.entities.Message
|
||||
import me.capcom.smsgateway.data.entities.MessageRecipient
|
||||
import me.capcom.smsgateway.data.entities.MessageState
|
||||
import me.capcom.smsgateway.data.entities.RecipientState
|
||||
import me.capcom.smsgateway.data.entities.Token
|
||||
import me.capcom.smsgateway.modules.incoming.db.IncomingMessage
|
||||
import me.capcom.smsgateway.modules.incoming.db.IncomingMessagesDao
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntriesDao
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntry
|
||||
import me.capcom.smsgateway.modules.webhooks.db.WebHook
|
||||
import me.capcom.smsgateway.modules.webhooks.db.WebHooksDao
|
||||
import me.capcom.smsgateway.modules.webhooks.db.WebhookQueueDao
|
||||
import me.capcom.smsgateway.modules.webhooks.db.WebhookQueueEntity
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
Message::class,
|
||||
MessageRecipient::class,
|
||||
RecipientState::class,
|
||||
MessageState::class,
|
||||
WebHook::class,
|
||||
WebhookQueueEntity::class,
|
||||
LogEntry::class,
|
||||
Token::class,
|
||||
IncomingMessage::class,
|
||||
],
|
||||
version = 20,
|
||||
autoMigrations = [
|
||||
AutoMigration(from = 1, to = 2),
|
||||
AutoMigration(from = 2, to = 3),
|
||||
AutoMigration(from = 3, to = 4),
|
||||
AutoMigration(from = 4, to = 5),
|
||||
AutoMigration(from = 5, to = 6),
|
||||
AutoMigration(from = 6, to = 7),
|
||||
// AutoMigration(from = 7, to = 8), // manual migration
|
||||
AutoMigration(from = 8, to = 9),
|
||||
AutoMigration(from = 9, to = 10),
|
||||
AutoMigration(from = 10, to = 11),
|
||||
AutoMigration(from = 11, to = 12),
|
||||
AutoMigration(from = 12, to = 13),
|
||||
// AutoMigration(from = 13, to = 14), // manual migration
|
||||
AutoMigration(from = 14, to = 15),
|
||||
AutoMigration(from = 15, to = 16),
|
||||
AutoMigration(from = 16, to = 17),
|
||||
AutoMigration(from = 17, to = 18),
|
||||
AutoMigration(from = 18, to = 19),
|
||||
AutoMigration(from = 19, to = 20),
|
||||
]
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun messagesDao(): MessagesDao
|
||||
abstract fun webhooksDao(): WebHooksDao
|
||||
abstract fun webhookQueueDao(): WebhookQueueDao
|
||||
abstract fun logDao(): LogEntriesDao
|
||||
abstract fun incomingMessagesDao(): IncomingMessagesDao
|
||||
abstract fun tokensDao(): TokensDao
|
||||
|
||||
companion object {
|
||||
fun getDatabase(context: android.content.Context): AppDatabase {
|
||||
return Room.databaseBuilder(
|
||||
context,
|
||||
AppDatabase::class.java,
|
||||
"gateway"
|
||||
)
|
||||
.addMigrations(
|
||||
MIGRATION_7_8,
|
||||
MIGRATION_13_14,
|
||||
)
|
||||
.allowMainThreadQueries()
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package me.capcom.smsgateway.data
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonElement
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class Converters {
|
||||
private val gson = GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create()
|
||||
|
||||
@TypeConverter
|
||||
fun listToString(value: List<String>?): String? {
|
||||
return value?.let { gson.toJson(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun listFromString(value: String?): List<String>? {
|
||||
return value?.let { gson.fromJson(it, Array<String>::class.java).toList() }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun dateToString(value: Date?): String? {
|
||||
return value?.let { DATE_FORMAT.format(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun dateFromString(value: String?): Date? {
|
||||
return value?.let { DATE_FORMAT.parse(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun jsonToString(value: JsonElement?): String? {
|
||||
return value?.let { gson.toJson(it) }
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun stringToJson(value: String?): JsonElement? {
|
||||
return value?.let { gson.fromJson(it, JsonElement::class.java) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DATE_FORMAT =
|
||||
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US).apply {
|
||||
timeZone = TimeZone.getTimeZone("GMT")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package me.capcom.smsgateway.data
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
val MIGRATION_7_8 = object : Migration(7, 8) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL(
|
||||
"""
|
||||
UPDATE message
|
||||
SET validUntil = strftime('%FT%TZ', createdAt / 1000 + 86400, 'unixepoch')
|
||||
WHERE validUntil IS NULL AND state = 'Pending'
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_13_14 = object : Migration(13, 14) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
// Create a new table with the desired schema (without the text column)
|
||||
database.execSQL(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS message_new (
|
||||
`id` TEXT NOT NULL,
|
||||
`withDeliveryReport` INTEGER NOT NULL DEFAULT 1,
|
||||
`simNumber` INTEGER,
|
||||
`validUntil` TEXT,
|
||||
`isEncrypted` INTEGER NOT NULL DEFAULT 0,
|
||||
`skipPhoneValidation` INTEGER NOT NULL DEFAULT 0,
|
||||
`priority` INTEGER NOT NULL DEFAULT 0,
|
||||
`type` TEXT NOT NULL DEFAULT 'Text',
|
||||
`source` TEXT NOT NULL DEFAULT 'Local',
|
||||
`content` TEXT NOT NULL,
|
||||
`state` TEXT NOT NULL,
|
||||
`createdAt` INTEGER NOT NULL DEFAULT 0,
|
||||
`processedAt` INTEGER,
|
||||
PRIMARY KEY(`id`)
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
// Copy data from the old table to the new table
|
||||
database.execSQL(
|
||||
"""
|
||||
INSERT INTO message_new (
|
||||
id,
|
||||
withDeliveryReport,
|
||||
simNumber,
|
||||
validUntil,
|
||||
isEncrypted,
|
||||
skipPhoneValidation,
|
||||
priority,
|
||||
source,
|
||||
type,
|
||||
content,
|
||||
state,
|
||||
createdAt,
|
||||
processedAt
|
||||
) SELECT
|
||||
id,
|
||||
withDeliveryReport,
|
||||
simNumber,
|
||||
validUntil,
|
||||
isEncrypted,
|
||||
skipPhoneValidation,
|
||||
priority,
|
||||
source,
|
||||
'Text' AS type,
|
||||
'{"text": "' || replace(replace(text, '\\', '\\\\'), '"', '\\"') || '"}' AS content,
|
||||
state,
|
||||
createdAt,
|
||||
processedAt
|
||||
FROM message
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
// Drop the old table and rename the new table to the original name
|
||||
database.execSQL("DROP TABLE IF EXISTS message")
|
||||
database.execSQL("ALTER TABLE message_new RENAME TO message")
|
||||
|
||||
// Create indices
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_Message_state ON message (state)")
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_Message_createdAt ON message (createdAt)")
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_Message_processedAt ON message (processedAt)")
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package me.capcom.smsgateway.data
|
||||
|
||||
import org.koin.dsl.module
|
||||
|
||||
val dbModule = module {
|
||||
single { AppDatabase.getDatabase(get()) }
|
||||
single { get<AppDatabase>().messagesDao() }
|
||||
single { get<AppDatabase>().incomingMessagesDao() }
|
||||
single { get<AppDatabase>().webhooksDao() }
|
||||
single { get<AppDatabase>().webhookQueueDao() }
|
||||
single { get<AppDatabase>().logDao() }
|
||||
single { get<AppDatabase>().tokensDao() }
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
package me.capcom.smsgateway.data.dao
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
import me.capcom.smsgateway.data.entities.Message
|
||||
import me.capcom.smsgateway.data.entities.MessageRecipient
|
||||
import me.capcom.smsgateway.data.entities.MessageState
|
||||
import me.capcom.smsgateway.data.entities.MessageWithRecipients
|
||||
import me.capcom.smsgateway.data.entities.MessagesStats
|
||||
import me.capcom.smsgateway.data.entities.MessagesTotals
|
||||
import me.capcom.smsgateway.data.entities.RecipientState
|
||||
import me.capcom.smsgateway.domain.EntitySource
|
||||
import me.capcom.smsgateway.domain.ProcessingState
|
||||
|
||||
@Dao
|
||||
interface MessagesDao {
|
||||
//#region Read
|
||||
@Query("SELECT COUNT(*) as count, MAX(processedAt) as lastTimestamp FROM message WHERE state <> 'Pending' AND state <> 'Failed' AND processedAt >= :timestamp")
|
||||
fun countProcessedFrom(timestamp: Long): MessagesStats
|
||||
|
||||
@Query("SELECT COUNT(*) as count, MAX(processedAt) as lastTimestamp FROM message WHERE state = 'Failed' AND processedAt >= :timestamp")
|
||||
fun countFailedFrom(timestamp: Long): MessagesStats
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT
|
||||
COUNT(*) as total,
|
||||
COALESCE(SUM(CASE WHEN state = 'Pending' THEN 1 ELSE 0 END), 0) as pending,
|
||||
COALESCE(SUM(CASE WHEN state = 'Sent' THEN 1 ELSE 0 END), 0) as sent,
|
||||
COALESCE(SUM(CASE WHEN state = 'Delivered' THEN 1 ELSE 0 END), 0) as delivered,
|
||||
COALESCE(SUM(CASE WHEN state = 'Failed' THEN 1 ELSE 0 END), 0) as failed
|
||||
FROM message
|
||||
"""
|
||||
)
|
||||
fun getMessagesStats(): LiveData<MessagesTotals>
|
||||
|
||||
@Query("SELECT * FROM message ORDER BY createdAt DESC LIMIT :limit")
|
||||
fun selectLast(limit: Int): LiveData<List<Message>>
|
||||
|
||||
/**
|
||||
* FIFO: oldest pending first (priority DESC, createdAt ASC)
|
||||
*/
|
||||
@Transaction
|
||||
@Query("SELECT *, `rowid` FROM message WHERE state = 'Pending' ORDER BY priority DESC, createdAt ASC LIMIT 1")
|
||||
fun getPendingFifo(): MessageWithRecipients?
|
||||
|
||||
/**
|
||||
* LIFO: newest pending first (priority DESC, createdAt DESC)
|
||||
*/
|
||||
@Transaction
|
||||
@Query("SELECT *, `rowid` FROM message WHERE state = 'Pending' ORDER BY priority DESC, createdAt DESC LIMIT 1")
|
||||
fun getPendingLifo(): MessageWithRecipients?
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT *, `rowid` FROM message WHERE id = :id")
|
||||
fun get(id: String): MessageWithRecipients?
|
||||
|
||||
/**
|
||||
* Count messages based on state and date range
|
||||
*/
|
||||
@Query("SELECT COUNT(*) as count FROM message WHERE source = :source AND (:state IS NULL OR state = :state) AND createdAt BETWEEN :start AND :end")
|
||||
fun count(source: EntitySource, state: ProcessingState?, start: Long, end: Long): Int
|
||||
|
||||
/**
|
||||
* Get messages with pagination and filtering
|
||||
*/
|
||||
@Transaction
|
||||
@Query("SELECT *, `rowid` FROM message WHERE source = :source AND (:state IS NULL OR state = :state) AND createdAt BETWEEN :start AND :end ORDER BY createdAt DESC LIMIT :limit OFFSET :offset")
|
||||
fun select(
|
||||
source: EntitySource,
|
||||
state: ProcessingState?,
|
||||
start: Long,
|
||||
end: Long,
|
||||
limit: Int,
|
||||
offset: Int
|
||||
): List<MessageWithRecipients>
|
||||
//#endregion
|
||||
|
||||
@Insert
|
||||
fun _insert(message: Message)
|
||||
|
||||
@Insert
|
||||
fun _insertRecipients(recipient: List<MessageRecipient>)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
fun _insertMessageState(state: MessageState)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
fun _insertRecipientStates(state: List<RecipientState>)
|
||||
|
||||
@Query(
|
||||
"INSERT INTO recipientstate(messageId, phoneNumber, state, updatedAt) " +
|
||||
"SELECT :messageId, phoneNumber, :state, strftime('%s', 'now') * 1000 " +
|
||||
"FROM messagerecipient " +
|
||||
"WHERE messageId = :messageId"
|
||||
)
|
||||
fun _insertRecipientStatesByMessage(
|
||||
messageId: String,
|
||||
state: me.capcom.smsgateway.domain.ProcessingState
|
||||
)
|
||||
|
||||
@Transaction
|
||||
fun insert(message: MessageWithRecipients) {
|
||||
_insert(message.message)
|
||||
_insertMessageState(
|
||||
MessageState(
|
||||
message.message.id,
|
||||
message.message.state,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
)
|
||||
_insertRecipients(message.recipients)
|
||||
_insertRecipientStates(message.recipients.map {
|
||||
RecipientState(
|
||||
message.message.id,
|
||||
it.phoneNumber,
|
||||
it.state,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@Query("UPDATE message SET state = :state WHERE id = :id AND state <> 'Failed'")
|
||||
fun _updateMessageState(id: String, state: me.capcom.smsgateway.domain.ProcessingState)
|
||||
|
||||
fun updateMessageState(id: String, state: me.capcom.smsgateway.domain.ProcessingState) {
|
||||
_updateMessageState(id, state)
|
||||
_insertMessageState(
|
||||
MessageState(
|
||||
id,
|
||||
state,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Query("UPDATE message SET state = 'Processed', processedAt = strftime('%s', 'now') * 1000 WHERE id = :id")
|
||||
fun _setMessageProcessed(id: String)
|
||||
fun setMessageProcessed(id: String) {
|
||||
_setMessageProcessed(id)
|
||||
_insertMessageState(
|
||||
MessageState(
|
||||
id,
|
||||
me.capcom.smsgateway.domain.ProcessingState.Processed,
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Query("UPDATE messagerecipient SET state = :state, error = :error WHERE messageId = :id AND phoneNumber = :phoneNumber AND state <> 'Failed'")
|
||||
fun _updateRecipientState(
|
||||
id: String,
|
||||
phoneNumber: String,
|
||||
state: me.capcom.smsgateway.domain.ProcessingState,
|
||||
error: String?
|
||||
)
|
||||
|
||||
@Transaction
|
||||
fun updateRecipientState(
|
||||
id: String,
|
||||
phoneNumber: String,
|
||||
state: me.capcom.smsgateway.domain.ProcessingState,
|
||||
error: String?
|
||||
) {
|
||||
_updateRecipientState(id, phoneNumber, state, error)
|
||||
_insertRecipientStates(
|
||||
listOf(
|
||||
RecipientState(id, phoneNumber, state, System.currentTimeMillis())
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Query("UPDATE messagerecipient SET state = :state, error = :error WHERE messageId = :id AND state <> 'Failed'")
|
||||
fun _updateRecipientsState(
|
||||
id: String,
|
||||
state: me.capcom.smsgateway.domain.ProcessingState,
|
||||
error: String?
|
||||
)
|
||||
|
||||
@Transaction
|
||||
fun updateRecipientsState(
|
||||
id: String,
|
||||
state: me.capcom.smsgateway.domain.ProcessingState,
|
||||
error: String?
|
||||
) {
|
||||
_updateRecipientsState(id, state, error)
|
||||
_insertRecipientStatesByMessage(id, state)
|
||||
}
|
||||
|
||||
@Query("UPDATE message SET simNumber = :simNumber WHERE id = :id")
|
||||
fun updateSimNumber(
|
||||
id: String,
|
||||
simNumber: Int
|
||||
)
|
||||
|
||||
@Query("UPDATE message SET partsCount = :partsCount WHERE id = :id")
|
||||
fun updatePartsCount(id: String, partsCount: Int)
|
||||
|
||||
@Query("DELETE FROM message WHERE createdAt < :until AND state <> 'Pending'")
|
||||
suspend fun truncateLog(until: Long)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.capcom.smsgateway.data.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import me.capcom.smsgateway.data.entities.Token
|
||||
|
||||
@Dao
|
||||
interface TokensDao {
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun insert(token: Token): Long
|
||||
|
||||
@Query("UPDATE tokens SET revokedAt = strftime('%s', 'now') * 1000 WHERE id = :id")
|
||||
suspend fun revoke(id: String)
|
||||
|
||||
@Query("SELECT EXISTS (SELECT 1 FROM tokens WHERE id = :id AND revokedAt IS NOT NULL)")
|
||||
suspend fun isRevoked(id: String): Boolean
|
||||
|
||||
@Query("DELETE FROM tokens WHERE expiresAt < strftime('%s', 'now') * 1000")
|
||||
suspend fun cleanup()
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.google.gson.Gson
|
||||
import me.capcom.smsgateway.domain.EntitySource
|
||||
import me.capcom.smsgateway.domain.MessageContent
|
||||
import me.capcom.smsgateway.domain.ProcessingState
|
||||
import java.util.Date
|
||||
|
||||
enum class MessageType {
|
||||
Text,
|
||||
Data,
|
||||
}
|
||||
|
||||
@Entity(
|
||||
indices = [
|
||||
androidx.room.Index(value = ["createdAt"]),
|
||||
androidx.room.Index(value = ["state", "processedAt"]),
|
||||
androidx.room.Index(value = ["state", "createdAt"]),
|
||||
]
|
||||
)
|
||||
data class Message constructor(
|
||||
@PrimaryKey val id: String,
|
||||
|
||||
@ColumnInfo(defaultValue = "1")
|
||||
val withDeliveryReport: Boolean,
|
||||
val simNumber: Int?,
|
||||
val validUntil: Date?,
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
val isEncrypted: Boolean,
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
val skipPhoneValidation: Boolean,
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
val priority: Byte,
|
||||
|
||||
@ColumnInfo(defaultValue = "Local")
|
||||
val source: EntitySource,
|
||||
|
||||
@ColumnInfo(defaultValue = "Text")
|
||||
val type: MessageType = MessageType.Text,
|
||||
|
||||
val content: String,
|
||||
|
||||
val state: ProcessingState = ProcessingState.Pending,
|
||||
val partsCount: Int? = null,
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
val createdAt: Long = System.currentTimeMillis(),
|
||||
val processedAt: Long? = null,
|
||||
) {
|
||||
constructor(
|
||||
id: String,
|
||||
withDeliveryReport: Boolean,
|
||||
simNumber: Int?,
|
||||
validUntil: Date?,
|
||||
isEncrypted: Boolean,
|
||||
skipPhoneValidation: Boolean,
|
||||
priority: Byte,
|
||||
source: EntitySource,
|
||||
|
||||
content: MessageContent,
|
||||
|
||||
createdAt: Long,
|
||||
) : this(
|
||||
id,
|
||||
withDeliveryReport,
|
||||
simNumber,
|
||||
validUntil,
|
||||
isEncrypted,
|
||||
skipPhoneValidation,
|
||||
priority,
|
||||
source,
|
||||
|
||||
content = gson.toJson(content),
|
||||
type = when (content) {
|
||||
is MessageContent.Text -> MessageType.Text
|
||||
is MessageContent.Data -> MessageType.Data
|
||||
},
|
||||
createdAt = createdAt,
|
||||
)
|
||||
|
||||
val textContent: MessageContent.Text?
|
||||
get() = when (type) {
|
||||
MessageType.Text -> gson.fromJson(content, MessageContent.Text::class.java)
|
||||
else -> null
|
||||
}
|
||||
|
||||
val dataContent: MessageContent.Data?
|
||||
get() = when (type) {
|
||||
MessageType.Data -> gson.fromJson(content, MessageContent.Data::class.java)
|
||||
else -> null
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PRIORITY_MIN: Byte = Byte.MIN_VALUE
|
||||
const val PRIORITY_DEFAULT: Byte = 0
|
||||
const val PRIORITY_EXPEDITED: Byte = 100
|
||||
|
||||
private val gson = Gson()
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
|
||||
@Entity(
|
||||
primaryKeys = ["messageId", "phoneNumber"],
|
||||
foreignKeys = [
|
||||
ForeignKey(entity = Message::class, parentColumns = ["id"], childColumns = ["messageId"], onDelete = ForeignKey.CASCADE)
|
||||
]
|
||||
)
|
||||
data class MessageRecipient(
|
||||
val messageId: String,
|
||||
val phoneNumber: String,
|
||||
val state: me.capcom.smsgateway.domain.ProcessingState = me.capcom.smsgateway.domain.ProcessingState.Pending,
|
||||
val error: String? = null
|
||||
)
|
||||
@@ -1,21 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
|
||||
@Entity(
|
||||
primaryKeys = ["messageId", "state"],
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = Message::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["messageId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)
|
||||
]
|
||||
)
|
||||
data class MessageState(
|
||||
val messageId: String,
|
||||
val state: me.capcom.smsgateway.domain.ProcessingState,
|
||||
val updatedAt: Long
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Relation
|
||||
|
||||
data class MessageWithRecipients(
|
||||
@Embedded val message: Message,
|
||||
@Relation(
|
||||
parentColumn = "id",
|
||||
entityColumn = "messageId",
|
||||
)
|
||||
val recipients: List<MessageRecipient>,
|
||||
@Relation(
|
||||
parentColumn = "id",
|
||||
entityColumn = "messageId",
|
||||
)
|
||||
val states: List<MessageState> = emptyList(),
|
||||
@ColumnInfo(name = "rowid")
|
||||
val rowId: Long = 0,
|
||||
) {
|
||||
val state: me.capcom.smsgateway.domain.ProcessingState
|
||||
get() = when {
|
||||
recipients.any { it.state == me.capcom.smsgateway.domain.ProcessingState.Pending } -> me.capcom.smsgateway.domain.ProcessingState.Pending
|
||||
recipients.any { it.state == me.capcom.smsgateway.domain.ProcessingState.Processed } -> me.capcom.smsgateway.domain.ProcessingState.Processed
|
||||
|
||||
recipients.all { it.state == me.capcom.smsgateway.domain.ProcessingState.Failed } -> me.capcom.smsgateway.domain.ProcessingState.Failed
|
||||
recipients.all { it.state == me.capcom.smsgateway.domain.ProcessingState.Delivered } -> me.capcom.smsgateway.domain.ProcessingState.Delivered
|
||||
else -> me.capcom.smsgateway.domain.ProcessingState.Sent
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
data class MessagesStats(
|
||||
val count: Int,
|
||||
val lastTimestamp: Long
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
data class MessagesTotals(
|
||||
val total: Long,
|
||||
val pending: Long,
|
||||
val sent: Long,
|
||||
val delivered: Long,
|
||||
val failed: Long,
|
||||
)
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
|
||||
@Entity(
|
||||
primaryKeys = ["messageId", "phoneNumber", "state"],
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MessageRecipient::class,
|
||||
parentColumns = ["messageId", "phoneNumber"],
|
||||
childColumns = ["messageId", "phoneNumber"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)
|
||||
]
|
||||
)
|
||||
data class RecipientState(
|
||||
val messageId: String,
|
||||
val phoneNumber: String,
|
||||
val state: me.capcom.smsgateway.domain.ProcessingState,
|
||||
val updatedAt: Long
|
||||
)
|
||||
@@ -1,18 +0,0 @@
|
||||
package me.capcom.smsgateway.data.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(
|
||||
tableName = "tokens",
|
||||
indices = [
|
||||
Index("expiresAt")
|
||||
],
|
||||
)
|
||||
data class Token(
|
||||
@PrimaryKey
|
||||
val id: String,
|
||||
val expiresAt: Long,
|
||||
val revokedAt: Long? = null,
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.capcom.smsgateway.domain
|
||||
|
||||
enum class EntitySource {
|
||||
Local,
|
||||
Cloud,
|
||||
|
||||
@Deprecated("Not used anymore")
|
||||
Gateway,
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.capcom.smsgateway.domain
|
||||
|
||||
import me.capcom.smsgateway.BuildConfig
|
||||
import me.capcom.smsgateway.modules.health.domain.CheckResult
|
||||
import me.capcom.smsgateway.modules.health.domain.HealthResult
|
||||
import me.capcom.smsgateway.modules.health.domain.Status
|
||||
|
||||
class HealthResponse(
|
||||
healthResult: HealthResult,
|
||||
|
||||
val version: String = BuildConfig.VERSION_NAME,
|
||||
val releaseId: Int = BuildConfig.VERSION_CODE,
|
||||
) {
|
||||
val status: Status = healthResult.status
|
||||
val checks: Map<String, CheckResult> = healthResult.checks
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package me.capcom.smsgateway.domain
|
||||
|
||||
sealed class MessageContent {
|
||||
data class Text(val text: String) : MessageContent() {
|
||||
override fun toString(): String {
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
data class Data(val data: String, val port: UShort) : MessageContent() {
|
||||
override fun toString(): String {
|
||||
return "$data:$port"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.capcom.smsgateway.domain
|
||||
|
||||
enum class ProcessingState {
|
||||
Pending,
|
||||
Processed,
|
||||
Sent,
|
||||
Delivered,
|
||||
Failed
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package me.capcom.smsgateway.extensions
|
||||
|
||||
import android.os.Build
|
||||
import com.google.gson.GsonBuilder
|
||||
import java.util.TimeZone
|
||||
|
||||
fun GsonBuilder.configure(): GsonBuilder {
|
||||
return this.setDateFormatISO8601()
|
||||
}
|
||||
|
||||
private fun GsonBuilder.setDateFormatISO8601(): GsonBuilder {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
this.setDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
|
||||
)
|
||||
} else {
|
||||
//get device timezone
|
||||
val timeZone = TimeZone.getDefault()
|
||||
this.setDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS" + when (timeZone.rawOffset) {
|
||||
0 -> "Z"
|
||||
else -> "+" + (timeZone.rawOffset / 3600000).toString().padStart(
|
||||
2,
|
||||
'0'
|
||||
) + ":" + ((timeZone.rawOffset % 3600000) / 60000).toString()
|
||||
.padStart(2, '0')
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package me.capcom.smsgateway.helpers
|
||||
|
||||
import me.capcom.smsgateway.BuildConfig
|
||||
|
||||
object BuildHelper {
|
||||
val isInsecureVersion =
|
||||
BuildConfig.BUILD_TYPE == "insecure" || BuildConfig.BUILD_TYPE == "debugInsecure"
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package me.capcom.smsgateway.helpers
|
||||
|
||||
import android.os.Build
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
object DateTimeParser {
|
||||
fun parseIsoDateTime(input: String): Date? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
parseModern(input)
|
||||
} else {
|
||||
parseLegacy(input)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("NewApi")
|
||||
private fun parseModern(input: String): Date? {
|
||||
return try {
|
||||
// Pattern handles both with/without milliseconds
|
||||
val formatter = java.time.format.DateTimeFormatter.ofPattern(
|
||||
"yyyy-MM-dd'T'HH:mm:ss[.SSS]XXX"
|
||||
)
|
||||
val offsetDateTime = java.time.OffsetDateTime.parse(input, formatter)
|
||||
Date.from(offsetDateTime.toInstant())
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseLegacy(input: String): Date? {
|
||||
// Try patterns in order of specificity
|
||||
val patterns = arrayOf(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", // With milliseconds
|
||||
"yyyy-MM-dd'T'HH:mm:ssXXX" // Without milliseconds
|
||||
)
|
||||
|
||||
for (pattern in patterns) {
|
||||
try {
|
||||
val sdf = SimpleDateFormat(pattern, Locale.US).apply {
|
||||
timeZone = TimeZone.getTimeZone("UTC")
|
||||
}
|
||||
return sdf.parse(input)
|
||||
} catch (e: ParseException) {
|
||||
// Try next pattern
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package me.capcom.smsgateway.helpers
|
||||
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil
|
||||
|
||||
object PhoneHelper {
|
||||
fun filterPhoneNumber(phoneNumber: String, countryCode: String): String {
|
||||
val phoneUtil = PhoneNumberUtil.getInstance()
|
||||
val number = phoneUtil.parse(phoneNumber, countryCode.uppercase())
|
||||
if (!phoneUtil.isValidNumber(number)) {
|
||||
throw RuntimeException("Invalid phone number")
|
||||
}
|
||||
if (phoneUtil.getNumberType(number) != PhoneNumberUtil.PhoneNumberType.MOBILE
|
||||
&& phoneUtil.getNumberType(number) != PhoneNumberUtil.PhoneNumberType.FIXED_LINE_OR_MOBILE
|
||||
) {
|
||||
throw RuntimeException("Invalid phone number type")
|
||||
}
|
||||
return phoneUtil.format(number, PhoneNumberUtil.PhoneNumberFormat.E164)
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package me.capcom.smsgateway.helpers
|
||||
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.sse.EventSource
|
||||
import okhttp3.sse.EventSourceListener
|
||||
import okhttp3.sse.EventSources
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
class SSEManager(
|
||||
private val url: String,
|
||||
private val authToken: String
|
||||
) {
|
||||
private val client = OkHttpClient.Builder()
|
||||
.readTimeout(1, TimeUnit.HOURS)
|
||||
.build()
|
||||
private val scope = CoroutineScope(Dispatchers.IO + Job())
|
||||
|
||||
private var eventSource: EventSource? = null
|
||||
private var reconnectAttempts = 0
|
||||
private val isDisconnecting = AtomicBoolean(false)
|
||||
|
||||
// Event callbacks
|
||||
var onEvent: ((type: String?, data: String) -> Unit)? = null
|
||||
var onConnected: (() -> Unit)? = null
|
||||
var onError: ((Throwable?) -> Unit)? = null
|
||||
var onClosed: (() -> Unit)? = null
|
||||
|
||||
fun connect() {
|
||||
isDisconnecting.set(false)
|
||||
scope.launch {
|
||||
try {
|
||||
val request = Request.Builder()
|
||||
.url(url)
|
||||
.apply {
|
||||
header("Authorization", "Bearer $authToken")
|
||||
}
|
||||
.build()
|
||||
|
||||
eventSource = EventSources.createFactory(client)
|
||||
.newEventSource(request, object : EventSourceListener() {
|
||||
override fun onOpen(eventSource: EventSource, response: Response) {
|
||||
Log.d(TAG, "SSE connected")
|
||||
reconnectAttempts = 0
|
||||
onConnected?.invoke()
|
||||
}
|
||||
|
||||
override fun onEvent(
|
||||
eventSource: EventSource,
|
||||
id: String?,
|
||||
type: String?,
|
||||
data: String
|
||||
) {
|
||||
Log.d(TAG, "Event received: $type - $data")
|
||||
onEvent?.invoke(type, data)
|
||||
}
|
||||
|
||||
override fun onClosed(eventSource: EventSource) {
|
||||
Log.d(TAG, "SSE connection closed")
|
||||
onClosed?.invoke()
|
||||
scheduleReconnect()
|
||||
}
|
||||
|
||||
override fun onFailure(
|
||||
eventSource: EventSource,
|
||||
t: Throwable?,
|
||||
response: Response?
|
||||
) {
|
||||
Log.e(TAG, "SSE error", t)
|
||||
onError?.invoke(t)
|
||||
scheduleReconnect()
|
||||
}
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Connection failed", e)
|
||||
scheduleReconnect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun disconnect() {
|
||||
isDisconnecting.set(true)
|
||||
scope.launch {
|
||||
eventSource?.cancel()
|
||||
eventSource = null
|
||||
reconnectAttempts = 0
|
||||
}
|
||||
scope.coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
private fun scheduleReconnect() {
|
||||
if (isDisconnecting.get()) {
|
||||
return
|
||||
}
|
||||
|
||||
reconnectAttempts++
|
||||
val delay = when {
|
||||
reconnectAttempts > 10 -> 60_000L // 1 minute
|
||||
reconnectAttempts > 5 -> 30_000L // 30 seconds
|
||||
else -> 5_000L // 5 seconds
|
||||
}
|
||||
|
||||
scope.launch {
|
||||
eventSource?.cancel()
|
||||
eventSource = null
|
||||
Log.d(TAG, "Reconnecting in ${delay}ms (attempt $reconnectAttempts)")
|
||||
kotlinx.coroutines.delay(delay)
|
||||
connect()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "SSEManager"
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package me.capcom.smsgateway.helpers
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import me.capcom.smsgateway.receivers.BootReceiver
|
||||
|
||||
class SettingsHelper(private val context: Context) {
|
||||
private val settings = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
init {
|
||||
migrate()
|
||||
}
|
||||
|
||||
var autostart: Boolean
|
||||
get() = settings.getBoolean(PREF_KEY_AUTOSTART, false)
|
||||
set(value) {
|
||||
// enable broadcast receiver
|
||||
context.packageManager.setComponentEnabledSetting(
|
||||
ComponentName(context, BootReceiver::class.java),
|
||||
if (value) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP
|
||||
)
|
||||
|
||||
settings.edit { putBoolean(PREF_KEY_AUTOSTART, value) }
|
||||
}
|
||||
|
||||
private fun migrate() {
|
||||
// remove after 2025-11-28
|
||||
val PREF_KEY_SERVER_TOKEN = "server_token"
|
||||
if (settings.contains(PREF_KEY_SERVER_TOKEN)) {
|
||||
settings.edit(true) {
|
||||
putString("localserver.PASSWORD", settings.getString(PREF_KEY_SERVER_TOKEN, null))
|
||||
remove(PREF_KEY_SERVER_TOKEN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PREF_KEY_AUTOSTART = "autostart"
|
||||
|
||||
private const val PREF_KEY_FCM_TOKEN = "fcm_token"
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package me.capcom.smsgateway.helpers
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.telephony.SubscriptionManager
|
||||
import androidx.core.app.ActivityCompat
|
||||
|
||||
object SubscriptionsHelper {
|
||||
@Suppress("DEPRECATION")
|
||||
fun getSubscriptionsManager(context: Context): SubscriptionManager? = when {
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1 -> null
|
||||
Build.VERSION.SDK_INT < 31 -> SubscriptionManager.from(context)
|
||||
else -> context.getSystemService(SubscriptionManager::class.java)
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun selectAvailableSimSlots(context: Context): Set<Int>? {
|
||||
if (!hasPhoneStatePermission(context)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val subscriptionManager = getSubscriptionsManager(context) ?: return null
|
||||
return when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 -> subscriptionManager.activeSubscriptionInfoList.map { it.simSlotIndex }
|
||||
.toSet()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun getSubscriptionId(context: Context, simSlotIndex: Int): Int? {
|
||||
if (!hasPhoneStatePermission(context)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val subscriptionManager = getSubscriptionsManager(context) ?: return null
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
subscriptionManager.activeSubscriptionInfoList.find {
|
||||
it.simSlotIndex == simSlotIndex
|
||||
}?.subscriptionId
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun getSimSlotIndex(context: Context, subscriptionId: Int): Int? {
|
||||
if (!hasPhoneStatePermission(context)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val subscriptionManager = getSubscriptionsManager(context) ?: return null
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
subscriptionManager.activeSubscriptionInfoList.find {
|
||||
it.subscriptionId == subscriptionId
|
||||
}?.simSlotIndex
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun hasPhoneStatePermission(context: Context): Boolean {
|
||||
return ActivityCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.READ_PHONE_STATE
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
fun extractSubscriptionId(context: Context, intent: Intent): Int? {
|
||||
return when {
|
||||
intent.extras?.containsKey(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX) == true -> intent.extras?.getInt(
|
||||
SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX
|
||||
)
|
||||
|
||||
intent.extras?.containsKey("subscription") == true -> intent.extras?.getInt("subscription")
|
||||
intent.extras?.containsKey(SubscriptionManager.EXTRA_SLOT_INDEX) == true -> intent.extras?.getInt(
|
||||
SubscriptionManager.EXTRA_SLOT_INDEX
|
||||
)?.let { getSubscriptionId(context, it) }
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun getPhoneNumber(context: Context, simSlotIndex: Int): String? {
|
||||
if (!hasPhoneStatePermission(context)) {
|
||||
return null
|
||||
}
|
||||
|
||||
val subscriptionManager = getSubscriptionsManager(context) ?: return null
|
||||
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
subscriptionManager.activeSubscriptionInfoList?.find {
|
||||
it.simSlotIndex == simSlotIndex
|
||||
}?.number?.takeIf { it.isNotBlank() }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.connection
|
||||
|
||||
enum class CellularNetworkType {
|
||||
None,
|
||||
Unknown,
|
||||
Mobile2G,
|
||||
Mobile3G,
|
||||
Mobile4G,
|
||||
Mobile5G,
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.connection
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.os.Build
|
||||
import android.telephony.TelephonyManager
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import me.capcom.smsgateway.modules.health.domain.CheckResult
|
||||
import me.capcom.smsgateway.modules.health.domain.Status
|
||||
import me.capcom.smsgateway.modules.logs.LogsService
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntry
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
class ConnectionService(
|
||||
private val context: Context
|
||||
) : KoinComponent {
|
||||
private val _status = MutableLiveData(false)
|
||||
val status: LiveData<Boolean> = _status
|
||||
|
||||
private val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
private val logsService by inject<LogsService>()
|
||||
|
||||
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||
override fun onLost(network: Network) {
|
||||
if (_status.value == false) return
|
||||
|
||||
logsService.insert(
|
||||
LogEntry.Priority.WARN,
|
||||
MODULE_NAME,
|
||||
"Internet connection lost"
|
||||
)
|
||||
|
||||
_status.postValue(false)
|
||||
|
||||
super.onLost(network)
|
||||
}
|
||||
|
||||
override fun onCapabilitiesChanged(
|
||||
network: Network,
|
||||
networkCapabilities: NetworkCapabilities
|
||||
) {
|
||||
val hasInternet =
|
||||
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
&& (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || networkCapabilities.hasCapability(
|
||||
NetworkCapabilities.NET_CAPABILITY_VALIDATED
|
||||
))
|
||||
|
||||
if (_status.value == hasInternet) return
|
||||
|
||||
logsService.insert(
|
||||
LogEntry.Priority.INFO,
|
||||
MODULE_NAME,
|
||||
"Internet connection status: $hasInternet"
|
||||
)
|
||||
|
||||
_status.postValue(hasInternet)
|
||||
|
||||
super.onCapabilitiesChanged(network, networkCapabilities)
|
||||
}
|
||||
}
|
||||
|
||||
fun healthCheck(): Map<String, CheckResult> {
|
||||
val status = when (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
true -> when (_status.value) {
|
||||
true -> Status.PASS
|
||||
else -> Status.FAIL
|
||||
}
|
||||
|
||||
false -> Status.PASS
|
||||
}
|
||||
val transport = transportType
|
||||
val cellularType = cellularNetworkType
|
||||
|
||||
return mapOf(
|
||||
"status" to CheckResult(
|
||||
status,
|
||||
when (status) {
|
||||
Status.PASS -> 1L
|
||||
else -> 0L
|
||||
},
|
||||
"boolean",
|
||||
"Internet connection status"
|
||||
),
|
||||
"transport" to CheckResult(
|
||||
when (transport.isEmpty()) {
|
||||
true -> Status.FAIL
|
||||
false -> Status.PASS
|
||||
},
|
||||
transport.sumOf { it.value }.toLong(),
|
||||
"flags",
|
||||
"Network transport type"
|
||||
),
|
||||
"cellular" to CheckResult(
|
||||
Status.PASS,
|
||||
cellularType.ordinal.toLong(),
|
||||
"index",
|
||||
"Cellular network type"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val transportType: Set<TransportType>
|
||||
get() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return setOf(TransportType.Unknown)
|
||||
|
||||
val result = mutableSetOf<TransportType>()
|
||||
|
||||
val nw = connectivityManager.activeNetwork ?: return result
|
||||
val actNw = connectivityManager.getNetworkCapabilities(nw) ?: return result
|
||||
|
||||
if (actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
||||
result.add(TransportType.WiFi)
|
||||
}
|
||||
if (actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
|
||||
result.add(TransportType.Ethernet)
|
||||
}
|
||||
if (actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
|
||||
result.add(TransportType.Cellular)
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
val cellularNetworkType: CellularNetworkType
|
||||
get() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return CellularNetworkType.Unknown
|
||||
|
||||
val transport = transportType
|
||||
|
||||
if (transport.contains(TransportType.Unknown)) {
|
||||
return CellularNetworkType.Unknown
|
||||
}
|
||||
if (!transport.contains(TransportType.Cellular)) {
|
||||
return CellularNetworkType.None
|
||||
}
|
||||
|
||||
val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.READ_PHONE_STATE
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
return CellularNetworkType.Unknown
|
||||
}
|
||||
when (tm.dataNetworkType) {
|
||||
TelephonyManager.NETWORK_TYPE_GPRS,
|
||||
TelephonyManager.NETWORK_TYPE_EDGE,
|
||||
TelephonyManager.NETWORK_TYPE_CDMA,
|
||||
TelephonyManager.NETWORK_TYPE_1xRTT,
|
||||
TelephonyManager.NETWORK_TYPE_IDEN,
|
||||
TelephonyManager.NETWORK_TYPE_GSM -> return CellularNetworkType.Mobile2G
|
||||
|
||||
TelephonyManager.NETWORK_TYPE_UMTS,
|
||||
TelephonyManager.NETWORK_TYPE_EVDO_0,
|
||||
TelephonyManager.NETWORK_TYPE_EVDO_A,
|
||||
TelephonyManager.NETWORK_TYPE_HSDPA,
|
||||
TelephonyManager.NETWORK_TYPE_HSUPA,
|
||||
TelephonyManager.NETWORK_TYPE_HSPA,
|
||||
TelephonyManager.NETWORK_TYPE_EVDO_B,
|
||||
TelephonyManager.NETWORK_TYPE_EHRPD,
|
||||
TelephonyManager.NETWORK_TYPE_HSPAP,
|
||||
TelephonyManager.NETWORK_TYPE_TD_SCDMA -> return CellularNetworkType.Mobile3G
|
||||
|
||||
TelephonyManager.NETWORK_TYPE_LTE,
|
||||
TelephonyManager.NETWORK_TYPE_IWLAN, 19 -> return CellularNetworkType.Mobile4G
|
||||
|
||||
TelephonyManager.NETWORK_TYPE_NR -> return CellularNetworkType.Mobile5G
|
||||
}
|
||||
|
||||
return CellularNetworkType.Unknown
|
||||
}
|
||||
|
||||
init {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
connectivityManager.registerDefaultNetworkCallback(networkCallback)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.connection
|
||||
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val connectionModule = module {
|
||||
singleOf(::ConnectionService)
|
||||
}
|
||||
|
||||
val MODULE_NAME = "connection"
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.connection
|
||||
|
||||
enum class TransportType(
|
||||
val value: Int
|
||||
) {
|
||||
Unknown(1),
|
||||
Cellular(2),
|
||||
WiFi(4),
|
||||
Ethernet(8),
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.encryption
|
||||
|
||||
import android.util.Base64
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.SecretKey
|
||||
import javax.crypto.SecretKeyFactory
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
import javax.crypto.spec.PBEKeySpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
class EncryptionService(
|
||||
private val settings: EncryptionSettings,
|
||||
) {
|
||||
fun decrypt(encryptedText: String): String {
|
||||
val chunks = encryptedText.split('$')
|
||||
if (chunks.size < 5)
|
||||
throw RuntimeException("Invalid encrypted data format")
|
||||
|
||||
if (chunks[1] != "aes-256-cbc/pbkdf2-sha1") {
|
||||
throw RuntimeException("Unsupported algorithm")
|
||||
}
|
||||
|
||||
val params = parseParams(chunks[2])
|
||||
if (!params.containsKey("i")) {
|
||||
throw RuntimeException("Missing iteration count")
|
||||
}
|
||||
|
||||
val salt = decode(chunks[3])
|
||||
val text = chunks[4]
|
||||
|
||||
val passphrase = requireNotNull(settings.passphrase) { "Passphrase is not set" }
|
||||
val secretKey = generateSecretKeyFromPassphrase(
|
||||
passphrase.toCharArray(),
|
||||
salt,
|
||||
256,
|
||||
params.getValue("i").toInt()
|
||||
)
|
||||
|
||||
return decryptText(text, secretKey, salt)
|
||||
}
|
||||
|
||||
private fun decryptText(encryptedText: String, secretKey: SecretKey, iv: ByteArray): String {
|
||||
val ivSpec = IvParameterSpec(iv)
|
||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivSpec)
|
||||
val encryptedBytes = decode(encryptedText)
|
||||
val decryptedBytes = cipher.doFinal(encryptedBytes)
|
||||
return String(decryptedBytes)
|
||||
}
|
||||
|
||||
private fun decode(input: String): ByteArray {
|
||||
return Base64.decode(input, Base64.DEFAULT)
|
||||
}
|
||||
|
||||
private fun generateSecretKeyFromPassphrase(
|
||||
passphrase: CharArray,
|
||||
salt: ByteArray,
|
||||
keyLength: Int = 256,
|
||||
iterationCount: Int = 300_000
|
||||
): SecretKey {
|
||||
val keySpec = PBEKeySpec(passphrase, salt, iterationCount, keyLength)
|
||||
val keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")
|
||||
val keyBytes = keyFactory.generateSecret(keySpec).encoded
|
||||
return SecretKeySpec(keyBytes, "AES")
|
||||
}
|
||||
|
||||
private fun parseParams(params: String): Map<String, String> {
|
||||
return params.split(',')
|
||||
.map { it.split('=', limit = 2) }
|
||||
.associate { it[0] to it[1] }
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.encryption
|
||||
|
||||
import me.capcom.smsgateway.modules.settings.Importer
|
||||
import me.capcom.smsgateway.modules.settings.KeyValueStorage
|
||||
import me.capcom.smsgateway.modules.settings.get
|
||||
|
||||
class EncryptionSettings(
|
||||
private val storage: KeyValueStorage,
|
||||
) : Importer {
|
||||
val passphrase: String?
|
||||
get() = storage.get<String>(PASSPHRASE)
|
||||
|
||||
private var version: Int
|
||||
get() = storage.get<Int>(VERSION) ?: 0
|
||||
set(value) = storage.set(VERSION, value)
|
||||
|
||||
init {
|
||||
migrate()
|
||||
}
|
||||
|
||||
private fun migrate() {
|
||||
if (version == VERSION_CODE) {
|
||||
return
|
||||
}
|
||||
|
||||
if (version < 1) {
|
||||
passphrase?.let {
|
||||
storage.set(PASSPHRASE, it)
|
||||
}
|
||||
}
|
||||
|
||||
version = VERSION_CODE
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val VERSION_CODE = 1
|
||||
|
||||
private const val PASSPHRASE = "passphrase"
|
||||
|
||||
private const val VERSION = "version"
|
||||
}
|
||||
|
||||
override fun import(data: Map<String, *>): Boolean {
|
||||
return data.map {
|
||||
when (it.key) {
|
||||
PASSPHRASE -> {
|
||||
val newValue = it.value?.toString()
|
||||
val changed = passphrase != newValue
|
||||
storage.set(it.key, newValue)
|
||||
changed
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}.any { it }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.encryption
|
||||
|
||||
import org.koin.dsl.module
|
||||
|
||||
val encryptionModule = module {
|
||||
single {
|
||||
EncryptionService(get())
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.events
|
||||
|
||||
open class AppEvent(
|
||||
@Transient
|
||||
val name: String,
|
||||
)
|
||||
@@ -1,24 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.events
|
||||
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
|
||||
class EventBus {
|
||||
private val _events = MutableSharedFlow<AppEvent>()
|
||||
val events = _events.asSharedFlow()
|
||||
|
||||
suspend fun emit(event: AppEvent) {
|
||||
Log.d("EventBus", "${Thread.currentThread().name} emitted ${event.name}")
|
||||
_events.emit(event)
|
||||
}
|
||||
|
||||
suspend inline fun <reified T : AppEvent> collect(crossinline block: suspend (T) -> Unit) {
|
||||
events
|
||||
.filter {
|
||||
it is T
|
||||
}
|
||||
.collect { block(it as T) }
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.events
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
|
||||
abstract class EventsReceiver : KoinComponent {
|
||||
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
private var job: Job? = null
|
||||
|
||||
private val eventBus = get<EventBus>()
|
||||
|
||||
fun start() {
|
||||
stop()
|
||||
|
||||
this.job = scope.launch {
|
||||
collect(eventBus)
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract suspend fun collect(eventBus: EventBus)
|
||||
|
||||
fun stop() {
|
||||
this.job?.cancel()
|
||||
this.job = null
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.events
|
||||
|
||||
data class ExternalEvent(
|
||||
val type: ExternalEventType,
|
||||
val data: String?,
|
||||
)
|
||||
@@ -1,17 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.events
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
enum class ExternalEventType {
|
||||
@SerializedName("MessageEnqueued")
|
||||
MessageEnqueued,
|
||||
|
||||
@SerializedName("WebhooksUpdated")
|
||||
WebhooksUpdated,
|
||||
|
||||
@SerializedName("MessagesExportRequested")
|
||||
MessagesExportRequested,
|
||||
|
||||
@SerializedName("SettingsUpdated")
|
||||
SettingsUpdated,
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.events
|
||||
|
||||
import org.koin.dsl.module
|
||||
|
||||
val eventBusModule = module {
|
||||
single { EventBus() }
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway
|
||||
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import me.capcom.smsgateway.domain.EntitySource
|
||||
import me.capcom.smsgateway.modules.events.EventBus
|
||||
import me.capcom.smsgateway.modules.events.EventsReceiver
|
||||
import me.capcom.smsgateway.modules.gateway.events.DeviceRegisteredEvent
|
||||
import me.capcom.smsgateway.modules.gateway.events.MessageEnqueuedEvent
|
||||
import me.capcom.smsgateway.modules.gateway.events.SettingsUpdatedEvent
|
||||
import me.capcom.smsgateway.modules.gateway.events.WebhooksUpdatedEvent
|
||||
import me.capcom.smsgateway.modules.gateway.services.SSEForegroundService
|
||||
import me.capcom.smsgateway.modules.gateway.workers.PullMessagesWorker
|
||||
import me.capcom.smsgateway.modules.gateway.workers.SendStateWorker
|
||||
import me.capcom.smsgateway.modules.gateway.workers.SettingsUpdateWorker
|
||||
import me.capcom.smsgateway.modules.gateway.workers.WebhooksUpdateWorker
|
||||
import me.capcom.smsgateway.modules.messages.events.MessageStateChangedEvent
|
||||
import me.capcom.smsgateway.modules.ping.events.PingEvent
|
||||
import org.koin.core.component.get
|
||||
|
||||
class EventsReceiver : EventsReceiver() {
|
||||
|
||||
private val settings = get<GatewaySettings>()
|
||||
|
||||
override suspend fun collect(eventBus: EventBus) {
|
||||
coroutineScope {
|
||||
launch {
|
||||
Log.d("EventsReceiver", "launched MessageEnqueuedEvent")
|
||||
eventBus.collect<MessageEnqueuedEvent> { event ->
|
||||
Log.d("EventsReceiver", "Event: $event")
|
||||
|
||||
if (!settings.enabled) return@collect
|
||||
|
||||
PullMessagesWorker.start(get())
|
||||
}
|
||||
}
|
||||
launch {
|
||||
Log.d("EventsReceiver", "launched MessageStateChangedEvent")
|
||||
val allowedSources = setOf(EntitySource.Cloud, EntitySource.Gateway)
|
||||
eventBus.collect<MessageStateChangedEvent> { event ->
|
||||
Log.d("EventsReceiver", "Event: $event")
|
||||
|
||||
if (!settings.enabled) return@collect
|
||||
|
||||
if (event.source !in allowedSources) return@collect
|
||||
|
||||
SendStateWorker.start(get(), event.id)
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
Log.d("EventsReceiver", "launched PingEvent")
|
||||
eventBus.collect<PingEvent> {
|
||||
Log.d("EventsReceiver", "Event: $it")
|
||||
|
||||
if (!settings.enabled) return@collect
|
||||
|
||||
PullMessagesWorker.start(get())
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
Log.d("EventsReceiver", "launched WebhooksUpdatedEvent")
|
||||
eventBus.collect<WebhooksUpdatedEvent> {
|
||||
Log.d("EventsReceiver", "Event: $it")
|
||||
|
||||
if (!settings.enabled) return@collect
|
||||
|
||||
WebhooksUpdateWorker.start(get())
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
Log.d("EventsReceiver", "launched SettingsUpdatedEvent")
|
||||
eventBus.collect<SettingsUpdatedEvent> {
|
||||
Log.d("EventsReceiver", "Event: $it")
|
||||
|
||||
if (!settings.enabled) return@collect
|
||||
|
||||
SettingsUpdateWorker.start(get())
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
Log.d("EventsReceiver", "launched DeviceRegisteredEvent")
|
||||
eventBus.collect<DeviceRegisteredEvent> {
|
||||
Log.d("EventsReceiver", "Event: $it")
|
||||
|
||||
if (!settings.enabled) return@collect
|
||||
if (settings.fcmToken != null) return@collect
|
||||
|
||||
SSEForegroundService.start(get())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.engine.okhttp.OkHttp
|
||||
import io.ktor.client.plugins.UserAgent
|
||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.client.request.HttpRequestBuilder
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.request.header
|
||||
import io.ktor.client.request.parameter
|
||||
import io.ktor.client.request.patch
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.client.request.setBody
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpHeaders
|
||||
import io.ktor.http.Url
|
||||
import io.ktor.http.contentType
|
||||
import io.ktor.http.hostWithPort
|
||||
import io.ktor.serialization.gson.gson
|
||||
import io.ktor.util.encodeBase64
|
||||
import me.capcom.smsgateway.BuildConfig
|
||||
import me.capcom.smsgateway.domain.ProcessingState
|
||||
import me.capcom.smsgateway.extensions.configure
|
||||
import me.capcom.smsgateway.modules.webhooks.domain.WebHookEvent
|
||||
import java.util.Date
|
||||
|
||||
class GatewayApi(
|
||||
private val baseUrl: String,
|
||||
private val privateToken: String?
|
||||
) {
|
||||
val hostname: String
|
||||
get() = Url(baseUrl).hostWithPort
|
||||
|
||||
private val client = HttpClient(OkHttp) {
|
||||
install(UserAgent) {
|
||||
agent = "me.capcom.smsgateway/" + BuildConfig.VERSION_NAME
|
||||
}
|
||||
install(ContentNegotiation) {
|
||||
gson {
|
||||
configure()
|
||||
}
|
||||
}
|
||||
expectSuccess = true
|
||||
}
|
||||
|
||||
suspend fun getDevice(token: String?): DeviceGetResponse {
|
||||
return client.get("$baseUrl/device") {
|
||||
token?.let { bearerAuth(it) }
|
||||
}.body()
|
||||
}
|
||||
|
||||
suspend fun deviceRegister(
|
||||
request: DeviceRegisterRequest,
|
||||
credentials: Pair<String, String>?
|
||||
): DeviceRegisterResponse {
|
||||
return client.post("$baseUrl/device") {
|
||||
when {
|
||||
credentials != null -> basicAuth(credentials.first, credentials.second)
|
||||
privateToken != null -> bearerAuth(privateToken)
|
||||
}
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(request)
|
||||
}.body()
|
||||
}
|
||||
|
||||
suspend fun deviceRegister(
|
||||
request: DeviceRegisterRequest,
|
||||
code: String
|
||||
): DeviceRegisterResponse {
|
||||
return client.post("$baseUrl/device") {
|
||||
header("Authorization", "Code $code")
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(request)
|
||||
}.body()
|
||||
}
|
||||
|
||||
suspend fun devicePatch(token: String, request: DevicePatchRequest) {
|
||||
client.patch("$baseUrl/device") {
|
||||
bearerAuth(token)
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(request)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getMessages(token: String, processingOrder: ProcessingOrder): List<Message> {
|
||||
return client.get("$baseUrl/message") {
|
||||
parameter("order", processingOrder)
|
||||
bearerAuth(token)
|
||||
}.body()
|
||||
}
|
||||
|
||||
suspend fun patchMessages(token: String, request: List<MessagePatchRequest>) {
|
||||
client.patch("$baseUrl/message") {
|
||||
bearerAuth(token)
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(request)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getWebHooks(token: String): List<WebHook> {
|
||||
return client.get("$baseUrl/webhooks") {
|
||||
bearerAuth(token)
|
||||
}.body()
|
||||
}
|
||||
|
||||
suspend fun getUserCode(credentials: Pair<String, String>): GetUserCodeResponse {
|
||||
return client.get("$baseUrl/user/code") {
|
||||
basicAuth(credentials.first, credentials.second)
|
||||
}.body()
|
||||
}
|
||||
|
||||
suspend fun changeUserPassword(token: String, request: PasswordChangeRequest) {
|
||||
client.patch("$baseUrl/user/password") {
|
||||
bearerAuth(token)
|
||||
contentType(ContentType.Application.Json)
|
||||
setBody(request)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSettings(token: String): Map<String, *> {
|
||||
return client.get("$baseUrl/settings") {
|
||||
bearerAuth(token)
|
||||
}.body()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
private fun HttpRequestBuilder.bearerAuth(token: String) {
|
||||
header(HttpHeaders.Authorization, "Bearer $token")
|
||||
}
|
||||
|
||||
private fun HttpRequestBuilder.basicAuth(username: String, password: String) {
|
||||
header(HttpHeaders.Authorization, "Basic ${"$username:$password".encodeBase64()}")
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
data class DeviceGetResponse(
|
||||
val externalIp: String,
|
||||
)
|
||||
|
||||
data class DeviceRegisterRequest(
|
||||
val name: String,
|
||||
val pushToken: String?,
|
||||
)
|
||||
|
||||
data class DeviceRegisterResponse(
|
||||
val id: String,
|
||||
val token: String,
|
||||
val login: String,
|
||||
val password: String?,
|
||||
)
|
||||
|
||||
data class DevicePatchRequest(
|
||||
val id: String,
|
||||
val pushToken: String?,
|
||||
)
|
||||
|
||||
data class MessagePatchRequest(
|
||||
val id: String,
|
||||
val state: ProcessingState,
|
||||
val recipients: List<RecipientState>,
|
||||
val states: Map<ProcessingState, Date>
|
||||
)
|
||||
|
||||
data class PasswordChangeRequest(
|
||||
val currentPassword: String,
|
||||
val newPassword: String
|
||||
)
|
||||
|
||||
data class GetUserCodeResponse(
|
||||
val code: String,
|
||||
val validUntil: Date
|
||||
)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
sealed class MessageContent {
|
||||
class Text(
|
||||
val text: String,
|
||||
) : MessageContent()
|
||||
|
||||
class Data(
|
||||
val data: String,
|
||||
val port: UShort,
|
||||
) : MessageContent()
|
||||
}
|
||||
|
||||
data class Message(
|
||||
val id: String,
|
||||
@SerializedName("textMessage")
|
||||
val _textMessage: MessageContent.Text?,
|
||||
@SerializedName("dataMessage")
|
||||
val _dataMessage: MessageContent.Data?,
|
||||
val phoneNumbers: List<String>,
|
||||
val simNumber: Int?,
|
||||
val withDeliveryReport: Boolean?,
|
||||
val isEncrypted: Boolean?,
|
||||
val validUntil: Date?,
|
||||
val priority: Byte?,
|
||||
val createdAt: Date?,
|
||||
|
||||
@SerializedName("message")
|
||||
val _message: String?,
|
||||
) {
|
||||
val content: MessageContent
|
||||
get() = this._dataMessage
|
||||
?: this._textMessage
|
||||
?: _message?.let { MessageContent.Text(it) }
|
||||
?: throw RuntimeException("Invalid message content")
|
||||
}
|
||||
|
||||
data class RecipientState(
|
||||
val phoneNumber: String,
|
||||
val state: ProcessingState,
|
||||
val error: String?,
|
||||
)
|
||||
|
||||
data class WebHook(
|
||||
val id: String,
|
||||
val url: String,
|
||||
val event: WebHookEvent,
|
||||
)
|
||||
|
||||
enum class ProcessingOrder {
|
||||
@SerializedName("lifo")
|
||||
LIFO,
|
||||
|
||||
@SerializedName("fifo")
|
||||
FIFO;
|
||||
|
||||
override fun toString(): String {
|
||||
return this.name.lowercase()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,305 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import io.ktor.client.plugins.ClientRequestException
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import me.capcom.smsgateway.data.entities.MessageWithRecipients
|
||||
import me.capcom.smsgateway.domain.EntitySource
|
||||
import me.capcom.smsgateway.domain.MessageContent
|
||||
import me.capcom.smsgateway.modules.events.EventBus
|
||||
import me.capcom.smsgateway.modules.gateway.events.DeviceRegisteredEvent
|
||||
import me.capcom.smsgateway.modules.gateway.services.SSEForegroundService
|
||||
import me.capcom.smsgateway.modules.gateway.workers.PullMessagesWorker
|
||||
import me.capcom.smsgateway.modules.gateway.workers.SendStateWorker
|
||||
import me.capcom.smsgateway.modules.gateway.workers.SettingsUpdateWorker
|
||||
import me.capcom.smsgateway.modules.gateway.workers.WebhooksUpdateWorker
|
||||
import me.capcom.smsgateway.modules.logs.LogsService
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntry
|
||||
import me.capcom.smsgateway.modules.messages.MessagesService
|
||||
import me.capcom.smsgateway.modules.messages.MessagesSettings
|
||||
import me.capcom.smsgateway.modules.messages.data.SendParams
|
||||
import me.capcom.smsgateway.modules.messages.data.SendRequest
|
||||
import me.capcom.smsgateway.services.PushService
|
||||
import java.util.Date
|
||||
|
||||
class GatewayService(
|
||||
private val messagesService: MessagesService,
|
||||
private val settings: GatewaySettings,
|
||||
private val events: EventBus,
|
||||
private val logsService: LogsService,
|
||||
) {
|
||||
private val eventsReceiver by lazy { EventsReceiver() }
|
||||
|
||||
private var _api: GatewayApi? = null
|
||||
|
||||
private val api
|
||||
get() = _api ?: GatewayApi(
|
||||
settings.serverUrl,
|
||||
settings.privateToken
|
||||
).also { _api = it }
|
||||
|
||||
//region Start, stop, etc...
|
||||
fun start(context: Context) {
|
||||
if (!settings.enabled) return
|
||||
|
||||
PushService.register(context)
|
||||
PullMessagesWorker.start(context)
|
||||
WebhooksUpdateWorker.start(context)
|
||||
SettingsUpdateWorker.start(context)
|
||||
|
||||
eventsReceiver.start()
|
||||
}
|
||||
|
||||
fun stop(context: Context) {
|
||||
eventsReceiver.stop()
|
||||
|
||||
SSEForegroundService.stop(context)
|
||||
SettingsUpdateWorker.stop(context)
|
||||
WebhooksUpdateWorker.stop(context)
|
||||
PullMessagesWorker.stop(context)
|
||||
|
||||
this._api = null
|
||||
}
|
||||
|
||||
fun isActiveLiveData(context: Context) = PullMessagesWorker.getStateLiveData(context)
|
||||
//endregion
|
||||
|
||||
//region Account
|
||||
suspend fun getLoginCode(): GatewayApi.GetUserCodeResponse {
|
||||
val username = settings.username
|
||||
?: throw IllegalStateException("Username is not set")
|
||||
val password = settings.password
|
||||
?: throw IllegalStateException("Password is not set")
|
||||
|
||||
return api.getUserCode(username to password)
|
||||
}
|
||||
|
||||
suspend fun changePassword(current: String, new: String) {
|
||||
val info = settings.registrationInfo
|
||||
?: throw IllegalStateException("The device is not registered on the server")
|
||||
|
||||
this.api.changeUserPassword(
|
||||
info.token,
|
||||
GatewayApi.PasswordChangeRequest(current, new)
|
||||
)
|
||||
|
||||
settings.registrationInfo = info.copy(password = new)
|
||||
|
||||
events.emit(
|
||||
DeviceRegisteredEvent.Success(
|
||||
api.hostname,
|
||||
info.login,
|
||||
new,
|
||||
)
|
||||
)
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Device
|
||||
internal suspend fun registerDevice(
|
||||
pushToken: String?,
|
||||
registerMode: RegistrationMode
|
||||
) {
|
||||
if (!settings.enabled) return
|
||||
|
||||
val settings = settings.registrationInfo
|
||||
val accessToken = settings?.token
|
||||
|
||||
if (accessToken != null) {
|
||||
// if there's an access token, try to update push token
|
||||
try {
|
||||
updateDevice(pushToken)
|
||||
return
|
||||
} catch (e: ClientRequestException) {
|
||||
// if token is invalid, try to register new one
|
||||
if (e.response.status != HttpStatusCode.Unauthorized) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
val deviceName = "${Build.MANUFACTURER}/${Build.PRODUCT}"
|
||||
val request = GatewayApi.DeviceRegisterRequest(
|
||||
deviceName,
|
||||
pushToken
|
||||
)
|
||||
val response = when (registerMode) {
|
||||
RegistrationMode.Anonymous -> api.deviceRegister(request, null)
|
||||
is RegistrationMode.WithCode -> api.deviceRegister(request, registerMode.code)
|
||||
is RegistrationMode.WithCredentials -> api.deviceRegister(
|
||||
request,
|
||||
registerMode.login to registerMode.password
|
||||
)
|
||||
}
|
||||
|
||||
this.settings.fcmToken = pushToken
|
||||
this.settings.registrationInfo = response
|
||||
|
||||
events.emit(
|
||||
DeviceRegisteredEvent.Success(
|
||||
api.hostname,
|
||||
response.login,
|
||||
response.password,
|
||||
)
|
||||
)
|
||||
} catch (th: Throwable) {
|
||||
events.emit(
|
||||
DeviceRegisteredEvent.Failure(
|
||||
api.hostname,
|
||||
th.localizedMessage ?: th.message ?: th.toString()
|
||||
)
|
||||
)
|
||||
|
||||
throw th
|
||||
}
|
||||
}
|
||||
|
||||
internal suspend fun updateDevice(pushToken: String?) {
|
||||
if (!settings.enabled) return
|
||||
|
||||
val settings = settings.registrationInfo ?: return
|
||||
val accessToken = settings.token
|
||||
|
||||
api.devicePatch(
|
||||
accessToken,
|
||||
GatewayApi.DevicePatchRequest(
|
||||
settings.id,
|
||||
pushToken
|
||||
)
|
||||
)
|
||||
|
||||
this.settings.fcmToken = pushToken
|
||||
|
||||
events.emit(
|
||||
DeviceRegisteredEvent.Success(
|
||||
api.hostname,
|
||||
settings.login,
|
||||
settings.password,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
sealed class RegistrationMode {
|
||||
object Anonymous : RegistrationMode()
|
||||
class WithCredentials(val login: String, val password: String) : RegistrationMode()
|
||||
class WithCode(val code: String) : RegistrationMode()
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Messages
|
||||
internal suspend fun getNewMessages(context: Context) {
|
||||
if (!settings.enabled) return
|
||||
val settings = settings.registrationInfo ?: return
|
||||
val processingOrder = when (messagesService.processingOrder) {
|
||||
MessagesSettings.ProcessingOrder.LIFO -> GatewayApi.ProcessingOrder.LIFO
|
||||
MessagesSettings.ProcessingOrder.FIFO -> GatewayApi.ProcessingOrder.FIFO
|
||||
}
|
||||
val messages = api.getMessages(settings.token, processingOrder)
|
||||
for (message in messages) {
|
||||
try {
|
||||
processMessage(context, message)
|
||||
} catch (th: Throwable) {
|
||||
logsService.insert(
|
||||
LogEntry.Priority.ERROR,
|
||||
MODULE_NAME,
|
||||
"Failed to process message",
|
||||
mapOf(
|
||||
"message" to message,
|
||||
"exception" to th.stackTraceToString(),
|
||||
)
|
||||
)
|
||||
th.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun processMessage(context: Context, message: GatewayApi.Message) {
|
||||
val messageState = messagesService.getMessage(message.id)
|
||||
if (messageState != null) {
|
||||
SendStateWorker.start(context, message.id)
|
||||
return
|
||||
}
|
||||
|
||||
val request = SendRequest(
|
||||
EntitySource.Cloud,
|
||||
me.capcom.smsgateway.modules.messages.data.Message(
|
||||
message.id,
|
||||
when (val content = message.content) {
|
||||
is GatewayApi.MessageContent.Text -> MessageContent.Text(content.text)
|
||||
is GatewayApi.MessageContent.Data -> MessageContent.Data(
|
||||
content.data,
|
||||
content.port
|
||||
)
|
||||
},
|
||||
message.phoneNumbers,
|
||||
message.isEncrypted ?: false,
|
||||
message.createdAt ?: Date(),
|
||||
),
|
||||
SendParams(
|
||||
message.withDeliveryReport ?: true,
|
||||
skipPhoneValidation = true,
|
||||
simNumber = message.simNumber,
|
||||
validUntil = message.validUntil,
|
||||
priority = message.priority,
|
||||
)
|
||||
)
|
||||
messagesService.enqueueMessage(request)
|
||||
}
|
||||
|
||||
internal suspend fun sendState(
|
||||
message: MessageWithRecipients
|
||||
) {
|
||||
val settings = settings.registrationInfo ?: return
|
||||
|
||||
api.patchMessages(
|
||||
settings.token,
|
||||
listOf(
|
||||
GatewayApi.MessagePatchRequest(
|
||||
message.message.id,
|
||||
message.message.state,
|
||||
message.recipients.map {
|
||||
GatewayApi.RecipientState(
|
||||
it.phoneNumber,
|
||||
it.state,
|
||||
it.error
|
||||
)
|
||||
},
|
||||
message.states.associate { it.state to Date(it.updatedAt) }
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Webhooks
|
||||
internal suspend fun getWebHooks(): List<GatewayApi.WebHook> {
|
||||
val settings = settings.registrationInfo
|
||||
return if (settings != null) {
|
||||
api.getWebHooks(settings.token)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Settings
|
||||
internal suspend fun getSettings(): Map<String, *>? {
|
||||
val settings = settings.registrationInfo ?: return null
|
||||
|
||||
return api.getSettings(settings.token)
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region Utility
|
||||
suspend fun getPublicIP(): String {
|
||||
return GatewayApi(
|
||||
settings.serverUrl,
|
||||
settings.privateToken
|
||||
)
|
||||
.getDevice(settings.registrationInfo?.token)
|
||||
.externalIp
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway
|
||||
|
||||
import me.capcom.smsgateway.modules.settings.Exporter
|
||||
import me.capcom.smsgateway.modules.settings.Importer
|
||||
import me.capcom.smsgateway.modules.settings.KeyValueStorage
|
||||
import me.capcom.smsgateway.modules.settings.get
|
||||
|
||||
class GatewaySettings(
|
||||
private val storage: KeyValueStorage,
|
||||
) : Exporter, Importer {
|
||||
enum class NotificationChannel {
|
||||
AUTO,
|
||||
SSE_ONLY,
|
||||
}
|
||||
|
||||
var enabled: Boolean
|
||||
get() = storage.get<Boolean>(ENABLED) ?: false
|
||||
set(value) = storage.set(ENABLED, value)
|
||||
|
||||
val deviceId: String?
|
||||
get() = registrationInfo?.id
|
||||
|
||||
var registrationInfo: GatewayApi.DeviceRegisterResponse?
|
||||
get() = storage.get(REGISTRATION_INFO)
|
||||
set(value) = storage.set(REGISTRATION_INFO, value)
|
||||
|
||||
var fcmToken: String?
|
||||
get() = storage.get(FCM_TOKEN)
|
||||
set(value) = storage.set(FCM_TOKEN, value)
|
||||
|
||||
val username: String?
|
||||
get() = registrationInfo?.login
|
||||
val password: String?
|
||||
get() = registrationInfo?.password
|
||||
|
||||
// WhatSMS fork: hardcoded server. Campo de URL removido do UI.
|
||||
val serverUrl: String
|
||||
get() = WHATSMS_SERVER_URL
|
||||
|
||||
// WhatSMS fork: private token hardcoded para auto-registo sem configuração.
|
||||
// Token rotado periodicamente via rebuild do APK.
|
||||
val privateToken: String?
|
||||
get() = WHATSMS_PRIVATE_TOKEN
|
||||
|
||||
val notificationChannel: NotificationChannel
|
||||
get() = storage.get<NotificationChannel>(NOTIFICATION_CHANNEL) ?: NotificationChannel.AUTO
|
||||
|
||||
companion object {
|
||||
private const val REGISTRATION_INFO = "REGISTRATION_INFO"
|
||||
private const val ENABLED = "ENABLED"
|
||||
private const val FCM_TOKEN = "fcm_token"
|
||||
|
||||
private const val CLOUD_URL = "cloud_url"
|
||||
private const val PRIVATE_TOKEN = "private_token"
|
||||
private const val NOTIFICATION_CHANNEL = "notification_channel"
|
||||
|
||||
const val PUBLIC_URL = "https://api.sms-gate.app/mobile/v1"
|
||||
|
||||
// WhatSMS fork: server capcom6 privado da Descomplicar.
|
||||
const val WHATSMS_SERVER_URL = "https://smsgw.whatsms.pt/api/mobile/v1"
|
||||
|
||||
// WhatSMS fork: private_token do GATEWAY_TOKEN config do server.
|
||||
// Permite auto-registo silencioso de novos devices.
|
||||
const val WHATSMS_PRIVATE_TOKEN =
|
||||
"a6c877b0369bd68d77c1760a88ec1996c6b672353f4b6344"
|
||||
}
|
||||
|
||||
override fun export(): Map<String, *> {
|
||||
return mapOf(
|
||||
CLOUD_URL to serverUrl,
|
||||
NOTIFICATION_CHANNEL to notificationChannel.name,
|
||||
)
|
||||
}
|
||||
|
||||
override fun import(data: Map<String, *>): Boolean {
|
||||
return data.map {
|
||||
when (it.key) {
|
||||
CLOUD_URL -> {
|
||||
val url = it.value?.toString() ?: PUBLIC_URL
|
||||
if (url != null && !url.startsWith("https://")) {
|
||||
throw IllegalArgumentException("url must start with https://")
|
||||
}
|
||||
|
||||
val changed = serverUrl != url
|
||||
|
||||
storage.set(it.key, url)
|
||||
|
||||
changed
|
||||
}
|
||||
|
||||
PRIVATE_TOKEN -> {
|
||||
val newValue = it.value?.toString()
|
||||
val changed = privateToken != newValue
|
||||
|
||||
storage.set(it.key, newValue)
|
||||
|
||||
changed
|
||||
}
|
||||
|
||||
NOTIFICATION_CHANNEL -> {
|
||||
val newValue = it.value?.let { NotificationChannel.valueOf(it.toString()) }
|
||||
?: NotificationChannel.AUTO
|
||||
val changed = notificationChannel != newValue
|
||||
|
||||
storage.set(it.key, newValue.name)
|
||||
|
||||
changed
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}.any { it }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway
|
||||
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val gatewayModule = module {
|
||||
singleOf(::GatewayService)
|
||||
}
|
||||
|
||||
val MODULE_NAME = "gateway"
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.events
|
||||
|
||||
import me.capcom.smsgateway.modules.events.AppEvent
|
||||
|
||||
sealed class DeviceRegisteredEvent(
|
||||
val server: String,
|
||||
) : AppEvent(NAME) {
|
||||
class Success(
|
||||
server: String,
|
||||
val login: String,
|
||||
val password: String?,
|
||||
) : DeviceRegisteredEvent(server)
|
||||
|
||||
class Failure(
|
||||
server: String,
|
||||
val reason: String,
|
||||
) : DeviceRegisteredEvent(server)
|
||||
|
||||
companion object {
|
||||
const val NAME = "DeviceRegisteredEvent"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.events
|
||||
|
||||
import me.capcom.smsgateway.modules.events.AppEvent
|
||||
|
||||
class MessageEnqueuedEvent : AppEvent(NAME) {
|
||||
companion object {
|
||||
const val NAME = "MessageEnqueuedEvent"
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.events
|
||||
|
||||
import me.capcom.smsgateway.modules.events.AppEvent
|
||||
|
||||
class SettingsUpdatedEvent : AppEvent(NAME) {
|
||||
|
||||
companion object {
|
||||
const val NAME = "SettingsUpdatedEvent"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.events
|
||||
|
||||
import me.capcom.smsgateway.modules.events.AppEvent
|
||||
|
||||
class WebhooksUpdatedEvent : AppEvent(NAME) {
|
||||
companion object {
|
||||
const val NAME = "WebhooksUpdatedEvent"
|
||||
}
|
||||
}
|
||||
-162
@@ -1,162 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.services
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import me.capcom.smsgateway.R
|
||||
import me.capcom.smsgateway.helpers.SSEManager
|
||||
import me.capcom.smsgateway.modules.events.ExternalEvent
|
||||
import me.capcom.smsgateway.modules.events.ExternalEventType
|
||||
import me.capcom.smsgateway.modules.gateway.GatewaySettings
|
||||
import me.capcom.smsgateway.modules.gateway.workers.PullMessagesWorker
|
||||
import me.capcom.smsgateway.modules.logs.LogsService
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntry
|
||||
import me.capcom.smsgateway.modules.notifications.NotificationsService
|
||||
import me.capcom.smsgateway.modules.orchestrator.EventsRouter
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class SSEForegroundService : Service() {
|
||||
private val settings: GatewaySettings by inject()
|
||||
|
||||
private val eventsRouter by inject<EventsRouter>()
|
||||
|
||||
private val notificationsSvc: NotificationsService by inject()
|
||||
private val logsService: LogsService by inject()
|
||||
|
||||
private val wakeLock: PowerManager.WakeLock by lazy {
|
||||
(getSystemService(Context.POWER_SERVICE) as PowerManager).run {
|
||||
newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.javaClass.name)
|
||||
}
|
||||
}
|
||||
private val wifiLock: WifiManager.WifiLock by lazy {
|
||||
(getSystemService(Context.WIFI_SERVICE) as WifiManager).createWifiLock(
|
||||
WifiManager.WIFI_MODE_FULL_HIGH_PERF,
|
||||
this.javaClass.name
|
||||
)
|
||||
}
|
||||
|
||||
private val sseManager by lazy {
|
||||
SSEManager(
|
||||
"${settings.serverUrl}/events",
|
||||
requireNotNull(
|
||||
settings.registrationInfo?.token
|
||||
) { "Authentication token is required for SSE connection" }
|
||||
)
|
||||
.apply {
|
||||
onConnected = {
|
||||
Log.d("SSEForegroundService", "SSE connected, pulling pending messages")
|
||||
try {
|
||||
PullMessagesWorker.start(this@SSEForegroundService)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
logsService.insert(
|
||||
LogEntry.Priority.ERROR,
|
||||
"SSEForegroundService",
|
||||
"Failed to start PullMessagesWorker on connect",
|
||||
)
|
||||
}
|
||||
}
|
||||
onEvent = { event, data ->
|
||||
Log.d("SSEForegroundService", "$event: $data")
|
||||
|
||||
try {
|
||||
processEvent(event, data)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
|
||||
logsService.insert(
|
||||
LogEntry.Priority.ERROR,
|
||||
"SSEForegroundService",
|
||||
"Failed to process event",
|
||||
mapOf("event" to event, "data" to data)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
if (!wakeLock.isHeld) {
|
||||
wakeLock.acquire()
|
||||
}
|
||||
if (!wifiLock.isHeld) {
|
||||
wifiLock.acquire()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
val notification = notificationsSvc.makeNotification(
|
||||
this,
|
||||
NotificationsService.NOTIFICATION_ID_REALTIME_EVENTS,
|
||||
getString(R.string.listening_to_the_server_events)
|
||||
)
|
||||
|
||||
startForeground(NotificationsService.NOTIFICATION_ID_REALTIME_EVENTS, notification)
|
||||
|
||||
sseManager.connect()
|
||||
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun processEvent(event: String?, data: String) {
|
||||
val type = try {
|
||||
event?.let { ExternalEventType.valueOf(it) }
|
||||
?: ExternalEventType.MessageEnqueued
|
||||
} catch (e: Throwable) {
|
||||
throw RuntimeException("Unknown event type: $event", e)
|
||||
}
|
||||
|
||||
eventsRouter.route(
|
||||
ExternalEvent(
|
||||
type = type,
|
||||
data = data
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
sseManager.disconnect()
|
||||
if (wifiLock.isHeld) {
|
||||
wifiLock.release()
|
||||
}
|
||||
if (wakeLock.isHeld) {
|
||||
wakeLock.release()
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
stopForeground(true)
|
||||
}
|
||||
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun start(context: Context) {
|
||||
val intent = Intent(context, SSEForegroundService::class.java)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(intent)
|
||||
} else {
|
||||
context.startService(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun stop(context: Context) {
|
||||
context.stopService(Intent(context, SSEForegroundService::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.map
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkRequest
|
||||
import androidx.work.WorkerParameters
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import me.capcom.smsgateway.App
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class PullMessagesWorker(
|
||||
appContext: Context,
|
||||
params: WorkerParameters
|
||||
) : CoroutineWorker(appContext, params) {
|
||||
override suspend fun doWork(): Result {
|
||||
try {
|
||||
withContext(Dispatchers.IO) {
|
||||
App.instance.gatewayService.getNewMessages(
|
||||
applicationContext
|
||||
)
|
||||
}
|
||||
return Result.success()
|
||||
} catch (th: Throwable) {
|
||||
th.printStackTrace()
|
||||
return Result.retry()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val NAME = "PullMessagesWorker"
|
||||
|
||||
fun start(context: Context) {
|
||||
val work = PeriodicWorkRequestBuilder<PullMessagesWorker>(PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS, TimeUnit.MILLISECONDS)
|
||||
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, WorkRequest.MIN_BACKOFF_MILLIS, TimeUnit.MILLISECONDS)
|
||||
.setConstraints(
|
||||
Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniquePeriodicWork(
|
||||
NAME,
|
||||
ExistingPeriodicWorkPolicy.REPLACE,
|
||||
work
|
||||
)
|
||||
}
|
||||
|
||||
fun getStateLiveData(context: Context) = WorkManager.getInstance(context)
|
||||
.getWorkInfosForUniqueWorkLiveData(NAME)
|
||||
.map { infos -> infos.any { it.state == WorkInfo.State.RUNNING || it.state == WorkInfo.State.ENQUEUED } }
|
||||
|
||||
fun stop(context: Context) {
|
||||
WorkManager.getInstance(context)
|
||||
.cancelUniqueWork(NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkRequest
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.work.workDataOf
|
||||
import me.capcom.smsgateway.App
|
||||
import me.capcom.smsgateway.modules.gateway.GatewayService
|
||||
import me.capcom.smsgateway.modules.logs.LogsService
|
||||
import me.capcom.smsgateway.modules.logs.db.LogEntry
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RegistrationWorker(
|
||||
appContext: Context,
|
||||
params: WorkerParameters
|
||||
) : CoroutineWorker(appContext, params), KoinComponent {
|
||||
private val logsSvc: LogsService by inject()
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
try {
|
||||
val token = inputData.getString(DATA_TOKEN)
|
||||
val isUpdate = inputData.getBoolean(DATA_IS_UPDATE, false)
|
||||
|
||||
when (isUpdate) {
|
||||
true -> App.instance.gatewayService.updateDevice(token ?: return Result.success())
|
||||
false -> App.instance.gatewayService.registerDevice(
|
||||
token,
|
||||
GatewayService.RegistrationMode.Anonymous
|
||||
)
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
} catch (e: Exception) {
|
||||
logsSvc.insert(
|
||||
priority = LogEntry.Priority.ERROR,
|
||||
module = NAME,
|
||||
message = "Registration failed: ${e.message}",
|
||||
context = mapOf(
|
||||
"token" to inputData.getString(DATA_TOKEN)
|
||||
)
|
||||
)
|
||||
e.printStackTrace()
|
||||
return Result.retry()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NAME = "RegistrationWorker"
|
||||
|
||||
private const val DATA_TOKEN = "token"
|
||||
private const val DATA_IS_UPDATE = "isUpdate"
|
||||
|
||||
fun start(context: Context, token: String?, isUpdate: Boolean) {
|
||||
val work = OneTimeWorkRequestBuilder<RegistrationWorker>()
|
||||
.setConstraints(
|
||||
Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
)
|
||||
.setBackoffCriteria(
|
||||
BackoffPolicy.EXPONENTIAL,
|
||||
WorkRequest.MIN_BACKOFF_MILLIS,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
.setInputData(
|
||||
workDataOf(
|
||||
DATA_TOKEN to token,
|
||||
DATA_IS_UPDATE to isUpdate,
|
||||
)
|
||||
)
|
||||
.build()
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniqueWork(
|
||||
NAME,
|
||||
ExistingWorkPolicy.REPLACE,
|
||||
work
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkRequest
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.work.workDataOf
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import me.capcom.smsgateway.modules.gateway.GatewayService
|
||||
import me.capcom.smsgateway.modules.messages.MessagesService
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SendStateWorker(appContext: Context, params: WorkerParameters) :
|
||||
CoroutineWorker(appContext, params), KoinComponent {
|
||||
private val messagesService: MessagesService by inject()
|
||||
private val gatewayService: GatewayService by inject()
|
||||
override suspend fun doWork(): Result {
|
||||
try {
|
||||
val messageId = inputData.getString(MESSAGE_ID) ?: return Result.failure()
|
||||
val message = messagesService.getMessage(messageId) ?: return Result.failure()
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
gatewayService.sendState(message)
|
||||
}
|
||||
return Result.success()
|
||||
} catch (th: Throwable) {
|
||||
th.printStackTrace()
|
||||
return when {
|
||||
this.runAttemptCount < RETRY_COUNT -> Result.retry()
|
||||
else -> Result.failure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val RETRY_COUNT = 10
|
||||
|
||||
private const val MESSAGE_ID = "messageId"
|
||||
|
||||
fun start(context: Context, messageId: String) {
|
||||
val work = OneTimeWorkRequestBuilder<SendStateWorker>()
|
||||
.setInputData(workDataOf(MESSAGE_ID to messageId))
|
||||
.setBackoffCriteria(
|
||||
BackoffPolicy.EXPONENTIAL,
|
||||
WorkRequest.MIN_BACKOFF_MILLIS,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
.setConstraints(
|
||||
Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
|
||||
WorkManager.getInstance(context)
|
||||
.enqueue(work)
|
||||
}
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkRequest
|
||||
import androidx.work.WorkerParameters
|
||||
import me.capcom.smsgateway.modules.gateway.GatewayService
|
||||
import me.capcom.smsgateway.modules.settings.SettingsService
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SettingsUpdateWorker(appContext: Context, params: WorkerParameters) :
|
||||
CoroutineWorker(appContext, params), KoinComponent {
|
||||
override suspend fun doWork(): Result {
|
||||
val gatewaySvc: GatewayService = get()
|
||||
val settingsSvc: SettingsService = get()
|
||||
|
||||
return try {
|
||||
val settings = gatewaySvc.getSettings()
|
||||
|
||||
settings?.let {
|
||||
settingsSvc.update(settings)
|
||||
}
|
||||
|
||||
Result.success()
|
||||
} catch (th: Throwable) {
|
||||
th.printStackTrace()
|
||||
Result.retry()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NAME = "SettingsUpdateWorker"
|
||||
|
||||
fun start(context: Context) {
|
||||
val work = PeriodicWorkRequestBuilder<SettingsUpdateWorker>(
|
||||
24,
|
||||
TimeUnit.HOURS
|
||||
)
|
||||
.setBackoffCriteria(
|
||||
BackoffPolicy.EXPONENTIAL,
|
||||
WorkRequest.MIN_BACKOFF_MILLIS,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
.setConstraints(
|
||||
Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniquePeriodicWork(
|
||||
NAME,
|
||||
ExistingPeriodicWorkPolicy.REPLACE,
|
||||
work
|
||||
)
|
||||
}
|
||||
|
||||
fun stop(context: Context) {
|
||||
WorkManager.getInstance(context)
|
||||
.cancelUniqueWork(NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.gateway.workers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkRequest
|
||||
import androidx.work.WorkerParameters
|
||||
import me.capcom.smsgateway.domain.EntitySource
|
||||
import me.capcom.smsgateway.modules.gateway.GatewayApi
|
||||
import me.capcom.smsgateway.modules.gateway.GatewayService
|
||||
import me.capcom.smsgateway.modules.webhooks.WebHooksService
|
||||
import me.capcom.smsgateway.modules.webhooks.domain.WebHookDTO
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class WebhooksUpdateWorker(appContext: Context, params: WorkerParameters) :
|
||||
CoroutineWorker(appContext, params), KoinComponent {
|
||||
override suspend fun doWork(): Result {
|
||||
val gatewaySvc: GatewayService = get()
|
||||
val webhookSvc: WebHooksService = get()
|
||||
|
||||
try {
|
||||
val webhooks = gatewaySvc.getWebHooks().map { it.toDTO() }
|
||||
webhookSvc.sync(EntitySource.Cloud, webhooks)
|
||||
} catch (th: Throwable) {
|
||||
th.printStackTrace()
|
||||
return Result.retry()
|
||||
}
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
private fun GatewayApi.WebHook.toDTO(): WebHookDTO {
|
||||
return WebHookDTO(
|
||||
id = id,
|
||||
deviceId = null,
|
||||
url = url,
|
||||
event = event,
|
||||
source = EntitySource.Cloud,
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NAME = "WebhooksUpdateWorker"
|
||||
|
||||
fun start(context: Context) {
|
||||
val work = PeriodicWorkRequestBuilder<WebhooksUpdateWorker>(
|
||||
24,
|
||||
TimeUnit.HOURS
|
||||
)
|
||||
.setBackoffCriteria(
|
||||
BackoffPolicy.EXPONENTIAL,
|
||||
WorkRequest.MIN_BACKOFF_MILLIS,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
.setConstraints(
|
||||
Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniquePeriodicWork(
|
||||
NAME,
|
||||
ExistingPeriodicWorkPolicy.REPLACE,
|
||||
work
|
||||
)
|
||||
}
|
||||
|
||||
fun stop(context: Context) {
|
||||
WorkManager.getInstance(context)
|
||||
.cancelUniqueWork(NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.health
|
||||
|
||||
import me.capcom.smsgateway.modules.connection.ConnectionService
|
||||
import me.capcom.smsgateway.modules.health.domain.HealthResult
|
||||
import me.capcom.smsgateway.modules.health.domain.Status
|
||||
import me.capcom.smsgateway.modules.health.monitors.BatteryMonitor
|
||||
import me.capcom.smsgateway.modules.messages.MessagesService
|
||||
|
||||
class HealthService(
|
||||
private val messagesSvc: MessagesService,
|
||||
private val connectionSvc: ConnectionService,
|
||||
private val batteryMon: BatteryMonitor,
|
||||
) {
|
||||
|
||||
fun healthCheck(): HealthResult {
|
||||
val messagesChecks = messagesSvc.healthCheck()
|
||||
val connectionChecks = connectionSvc.healthCheck()
|
||||
val batteryChecks = batteryMon.healthCheck()
|
||||
|
||||
val allChecks = messagesChecks.mapKeys { "messages:${it.key}" } +
|
||||
connectionChecks.mapKeys { "connection:${it.key}" } +
|
||||
batteryChecks.mapKeys { "battery:${it.key}" }
|
||||
|
||||
return HealthResult(
|
||||
when {
|
||||
allChecks.values.any { it.status == Status.FAIL } -> Status.FAIL
|
||||
allChecks.values.any { it.status == Status.WARN } -> Status.WARN
|
||||
else -> Status.PASS
|
||||
},
|
||||
allChecks
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import me.capcom.smsgateway.modules.health.HealthService
|
||||
import me.capcom.smsgateway.modules.health.monitors.BatteryMonitor
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val healthModule = module {
|
||||
singleOf(::BatteryMonitor)
|
||||
singleOf(::HealthService)
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.health.domain
|
||||
|
||||
data class CheckResult(
|
||||
val status: Status,
|
||||
val observedValue: Long,
|
||||
val observedUnit: String,
|
||||
val description: String,
|
||||
)
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.capcom.smsgateway.modules.health.domain
|
||||
|
||||
data class HealthResult(
|
||||
val status: Status,
|
||||
val checks: Map<String, CheckResult>
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user