Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9ac92a0c4 | ||
| cb44bc92e4 | |||
| bc07974b4b | |||
|
|
abe44f6ad1 | ||
| c17e1c74ee | |||
|
|
255bfe2262 | ||
| 8eea325e21 | |||
| 3afb2ee80d | |||
|
|
245188c1a1 | ||
| 1d2057d75a | |||
| d8343d089b | |||
|
|
5cc087330c | ||
| 4163f22f71 | |||
|
|
ed0761bd20 | ||
| 6fdaa8dfd3 | |||
|
|
88d0a3f887 | ||
| 240d39593e | |||
| f06d11711b | |||
|
|
75e1fe6812 | ||
| f8c1e0641d | |||
| 6795e692d6 | |||
|
|
1c42974fe8 | ||
| 2cde79e87d | |||
|
|
6ec54c6018 | ||
| e203a46b5a | |||
|
|
746b7e6166 | ||
| 0d089d0244 | |||
|
|
1302bead0e | ||
| 875c4d3b54 | |||
|
|
bc3de084d2 | ||
| 849f4b980d | |||
|
|
f7b79b3e20 | ||
| 149ebfbe1f | |||
|
|
684b74a890 | ||
| b2538670cd | |||
|
|
da9f19e331 | ||
| 91bf4d6053 | |||
| 6ef5fcc2ed | |||
|
|
1f74a133a5 | ||
| 61946d5842 | |||
|
|
e634217d81 | ||
| 84ab4a76dd | |||
| dc5a416949 | |||
| 1bfb18ba86 | |||
|
|
49cc17d105 | ||
| 174d62e68a | |||
|
|
0d61eed963 | ||
| 4f58736f7f | |||
|
|
f6cf5696dd | ||
| 2ca09bbdf0 | |||
| c39a0ae248 | |||
|
|
1e848bc622 | ||
| 3fe00eb3d7 | |||
| 85851d7288 |
@@ -28,14 +28,18 @@ jobs:
|
||||
run: |
|
||||
CURRENT=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
||||
echo "Current version: $CURRENT"
|
||||
|
||||
MAJOR=$(echo $CURRENT | cut -d. -f1)
|
||||
MINOR=$(echo $CURRENT | cut -d. -f2)
|
||||
PATCH=$(echo $CURRENT | cut -d. -f3)
|
||||
NEW_PATCH=$((PATCH + 1))
|
||||
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" package.json
|
||||
|
||||
grep '"version"' package.json | head -1
|
||||
|
||||
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "SHOULD_BUILD=true" >> $GITHUB_OUTPUT
|
||||
|
||||
@@ -47,7 +51,7 @@ jobs:
|
||||
git commit -m "chore: bump version to ${{ steps.bump.outputs.VERSION }} [skip ci]"
|
||||
git push
|
||||
|
||||
build-and-release:
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
needs: increment-version
|
||||
if: always() && (needs.increment-version.outputs.should_build == 'true' || needs.increment-version.result == 'skipped')
|
||||
@@ -56,7 +60,6 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: false
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
@@ -82,17 +85,46 @@ jobs:
|
||||
uses: android-actions/setup-android@v3
|
||||
|
||||
- name: Install dependencies (root)
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
- name: Apply overlay
|
||||
run: npm run apply-overlay
|
||||
|
||||
- name: Install dependencies (cinny)
|
||||
working-directory: ./cinny
|
||||
run: npm install --prefer-offline
|
||||
|
||||
- name: Clean previous cinny dist
|
||||
- name: Clean previous builds
|
||||
run: rm -rf cinny/dist
|
||||
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x android/gradlew
|
||||
|
||||
- name: Apply overlay and build Android APK
|
||||
- name: Build Android APK
|
||||
run: npm run android:apk:linux
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Paarrot-Android.apk
|
||||
path: android/app/build/outputs/apk/debug/Paarrot-*.apk
|
||||
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [increment-version, build-android]
|
||||
if: always() && needs.build-android.result == 'success'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
- name: Pull latest (after version bump)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: git pull origin master
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: |
|
||||
@@ -109,8 +141,10 @@ jobs:
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
||||
echo "Tag v$VERSION already exists"
|
||||
echo "exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Tag v$VERSION does not exist"
|
||||
echo "exists=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
@@ -122,7 +156,18 @@ jobs:
|
||||
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
|
||||
git push origin "v${{ steps.version.outputs.VERSION }}"
|
||||
|
||||
- name: Create or Update Release
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Prepare release files
|
||||
run: |
|
||||
mkdir -p release-files
|
||||
find artifacts -type f -name "*.apk" -exec cp {} release-files/ \;
|
||||
ls -la release-files/
|
||||
|
||||
- name: Create or Update Gitea Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
@@ -131,13 +176,6 @@ jobs:
|
||||
API_BASE="http://synbox.ruv.wtf:8418/api/v1"
|
||||
REPO="litruv/cinny-mobile"
|
||||
|
||||
APK=$(find android/app/build/outputs/apk/debug -name "Paarrot-*.apk" | head -1)
|
||||
if [ -z "$APK" ]; then
|
||||
echo "No APK found!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Found APK: $APK"
|
||||
|
||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
||||
|
||||
@@ -150,22 +188,67 @@ jobs:
|
||||
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
|
||||
echo "Created release with ID: ${RELEASE_ID}"
|
||||
else
|
||||
echo "Release exists with ID: ${RELEASE_ID}, deleting existing assets..."
|
||||
echo "Release exists with ID: ${RELEASE_ID}"
|
||||
echo "Deleting existing assets..."
|
||||
ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
|
||||
for ASSET_ID in $ASSETS; do
|
||||
echo "Deleting asset ${ASSET_ID}..."
|
||||
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Uploading assets..."
|
||||
for FILE in release-files/*; do
|
||||
FILENAME="Paarrot-${VERSION}.apk"
|
||||
echo "Uploading ${FILENAME}..."
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@${APK}" \
|
||||
--data-binary "@${FILE}" \
|
||||
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "Release complete!"
|
||||
echo "Gitea release complete!"
|
||||
|
||||
- name: Create GitHub Release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Mobile"
|
||||
|
||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Creating new GitHub release for ${TAG_NAME}..."
|
||||
RELEASE_ID=$(curl -s -X POST \
|
||||
-H "Authorization: token ${GH_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases" | jq -r '.id')
|
||||
echo "Created GitHub release with ID: ${RELEASE_ID}"
|
||||
else
|
||||
echo "GitHub release exists with ID: ${RELEASE_ID}"
|
||||
fi
|
||||
|
||||
echo "Uploading assets to GitHub..."
|
||||
UPLOAD_URL=$(curl -s -H "Authorization: token ${GH_TOKEN}" \
|
||||
"https://api.github.com/repos/${GITHUB_REPO}/releases/${RELEASE_ID}" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
||||
|
||||
for FILE in release-files/*; do
|
||||
FILENAME="Paarrot-${VERSION}.apk"
|
||||
echo "Uploading ${FILENAME} to GitHub..."
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${GH_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@${FILE}" \
|
||||
"${UPLOAD_URL}?name=${FILENAME}"
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "GitHub release complete!"
|
||||
|
||||
30
.gitea/workflows/clean.yml
Normal file
30
.gitea/workflows/clean.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Clean
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
clean:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Clean build artifacts
|
||||
run: |
|
||||
echo "Cleaning cinny dist..."
|
||||
rm -rf cinny/dist
|
||||
|
||||
echo "Cleaning Android build outputs..."
|
||||
rm -rf android/app/build
|
||||
|
||||
echo "Cleaning root node_modules..."
|
||||
rm -rf node_modules
|
||||
|
||||
echo "Cleaning cinny node_modules..."
|
||||
rm -rf cinny/node_modules
|
||||
|
||||
echo "Done."
|
||||
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
@@ -1,3 +0,0 @@
|
||||
github: ajbura
|
||||
liberapay: ajbura
|
||||
open_collective: cinny
|
||||
58
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
58
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,58 +0,0 @@
|
||||
name: 🐞 Bug Report
|
||||
description: Report a bug
|
||||
labels: 'type: bug'
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## First of all
|
||||
1. Please search for [existing issues](https://github.com/cinnyapp/cinny-desktop/issues?q=is%3Aissue) about this problem first.
|
||||
2. Make sure Cinny is up to date.
|
||||
3. Make sure it's an issue with Cinny and not something else you are using.
|
||||
4. Remember to be friendly.
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear description of what the bug is. Include screenshots if applicable.
|
||||
placeholder: Bug description
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Reproduction
|
||||
description: Steps to reproduce the behavior.
|
||||
placeholder: |
|
||||
1. Go to ...
|
||||
2. Click on ...
|
||||
3. See error
|
||||
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A clear description of what you expected to happen.
|
||||
|
||||
- type: textarea
|
||||
id: info
|
||||
attributes:
|
||||
label: Platform and versions
|
||||
description: "Provide OS, browser and Cinny version with your Homeserver."
|
||||
placeholder: |
|
||||
1. OS: [e.g. Windows 10, MacOS]
|
||||
2. Cinny version: [e.g. 1.8.1]
|
||||
3. Matrix homeserver: [e.g. matrix.org]
|
||||
4. Downloaded from: [e.g. GitHub, Flatpak]
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here.
|
||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,4 +0,0 @@
|
||||
contact_links:
|
||||
- name: 💬 Matrix Chat
|
||||
url: https://matrix.to/#/#cinny:matrix.org
|
||||
about: Ask questions and talk to other Cinny users and the maintainers
|
||||
34
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
34
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,34 +0,0 @@
|
||||
name: 💡 Feature Request
|
||||
description: Suggest an idea
|
||||
labels: 'type: feature'
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Describe the problem
|
||||
description: A clear description of the problem this feature would solve
|
||||
placeholder: "I'm always frustrated when..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: "Describe the solution you'd like"
|
||||
description: A clear description of what change you would like
|
||||
placeholder: "I would like to..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
description: "Any alternative solutions you've considered"
|
||||
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here.
|
||||
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,22 +0,0 @@
|
||||
<!-- Please read https://github.com/cinnyapp/cinny/blob/dev/CONTRIBUTING.md before submitting your pull request -->
|
||||
|
||||
### Description
|
||||
<!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. -->
|
||||
|
||||
|
||||
Fixes #
|
||||
|
||||
#### Type of change
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] This change requires a documentation update
|
||||
|
||||
### Checklist:
|
||||
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
3
.github/SECURITY.md
vendored
3
.github/SECURITY.md
vendored
@@ -1,3 +0,0 @@
|
||||
# Reporting a Vulnerability
|
||||
|
||||
**If you've found a security vulnerability, please report it to cinnyapp@gmail.com**
|
||||
30
.github/dependabot.yml
vendored
30
.github/dependabot.yml
vendored
@@ -1,30 +0,0 @@
|
||||
# Docs: <https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/customizing-dependency-updates>
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
# - package-ecosystem: npm
|
||||
# directory: /
|
||||
# schedule:
|
||||
# interval: weekly
|
||||
# day: "tuesday"
|
||||
# time: "01:00"
|
||||
# timezone: "Asia/Kolkata"
|
||||
# open-pull-requests-limit: 15
|
||||
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: "tuesday"
|
||||
time: "01:00"
|
||||
timezone: "Asia/Kolkata"
|
||||
open-pull-requests-limit: 5
|
||||
|
||||
# - package-ecosystem: cargo
|
||||
# directory: /src-tauri/
|
||||
# schedule:
|
||||
# interval: weekly
|
||||
# day: "tuesday"
|
||||
# time: "01:00"
|
||||
# timezone: "Asia/Kolkata"
|
||||
# open-pull-requests-limit: 5
|
||||
21
.github/renovate.json
vendored
21
.github/renovate.json
vendored
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":dependencyDashboardApproval"
|
||||
],
|
||||
"labels": [
|
||||
"Dependencies"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": [
|
||||
"lockFileMaintenance"
|
||||
]
|
||||
}
|
||||
],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true
|
||||
},
|
||||
"dependencyDashboard": true
|
||||
}
|
||||
22
.github/workflows/archive.yml
vendored
22
.github/workflows/archive.yml
vendored
@@ -1,22 +0,0 @@
|
||||
name: "Upload zip-archive"
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
zip-archive:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
with:
|
||||
submodules: true
|
||||
- name: Create zip including submodules
|
||||
run: |
|
||||
cd ..
|
||||
zip ${{ github.event.repository.name }}/${{ github.event.repository.name }}-${{ github.ref_name }}.zip ${{ github.event.repository.name }} -r
|
||||
- name: Upload zip to release
|
||||
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836
|
||||
with:
|
||||
files: |
|
||||
${{ github.event.repository.name }}-${{ github.ref_name }}.zip
|
||||
36
.github/workflows/cla.yml
vendored
36
.github/workflows/cla.yml
vendored
@@ -1,36 +0,0 @@
|
||||
name: 'CLA Assistant'
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_target:
|
||||
types: [opened, closed, synchronize]
|
||||
|
||||
jobs:
|
||||
CLAssistant:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'CLA Assistant'
|
||||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
|
||||
# Beta Release
|
||||
uses: cla-assistant/github-action@v2.6.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# the below token should have repo scope and must be manually added by you in the repository's secret
|
||||
PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_PAT }}
|
||||
with:
|
||||
path-to-signatures: 'signatures.json'
|
||||
path-to-document: 'https://github.com/cinnyapp/cla/blob/main/cla.md' # e.g. a CLA or a DCO document
|
||||
# branch should not be protected
|
||||
branch: 'main'
|
||||
allowlist: ajbura,bot*
|
||||
|
||||
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
|
||||
remote-organization-name: cinnyapp
|
||||
remote-repository-name: cla
|
||||
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
|
||||
#signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo'
|
||||
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
|
||||
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
|
||||
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
|
||||
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
|
||||
#use-dco-flag: true - If you are using DCO instead of CLA
|
||||
26
.github/workflows/lockfile.yml
vendored
26
.github/workflows/lockfile.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: NPM Lockfile Changes
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'package-lock.json'
|
||||
|
||||
jobs:
|
||||
lockfile_changes:
|
||||
runs-on: ubuntu-latest
|
||||
# Permission overwrite is required for Dependabot PRs, see "Common issues" below.
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.0
|
||||
- name: NPM Lockfile Changes
|
||||
uses: codepunkt/npm-lockfile-changes@b40543471c36394409466fdb277a73a0856d7891
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Optional inputs, can be deleted safely if you are happy with default values.
|
||||
collapsibleThreshold: 25
|
||||
failOnDowngrade: false
|
||||
path: package-lock.json
|
||||
updateComment: true
|
||||
40
.github/workflows/test.yml
vendored
40
.github/workflows/test.yml
vendored
@@ -1,40 +0,0 @@
|
||||
name: "Build pull request"
|
||||
on:
|
||||
#pull_request:
|
||||
#types: ['opened', 'synchronize']
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-20.04, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
with:
|
||||
submodules: true
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4.4.0
|
||||
with:
|
||||
node-version: 20.12.2
|
||||
cache: 'npm'
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1.0.7
|
||||
with:
|
||||
toolchain: stable
|
||||
- name: Install dependencies (ubuntu only)
|
||||
if: matrix.platform == 'ubuntu-20.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
- name: Install cinny dependencies
|
||||
run: cd cinny && npm ci
|
||||
- name: Install tauri dependencies
|
||||
run: npm ci
|
||||
- name: Build desktop app with Tauri
|
||||
uses: tauri-apps/tauri-action@v0.5.14
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
8
android/.gitignore
vendored
8
android/.gitignore
vendored
@@ -52,10 +52,10 @@ captures/
|
||||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||
.idea/navEditor.xml
|
||||
|
||||
# Keystore files
|
||||
# Uncomment the following lines if you do not want to check your keystore files in.
|
||||
#*.jks
|
||||
#*.keystore
|
||||
# Keystore files - NEVER commit these!
|
||||
*.jks
|
||||
*.keystore
|
||||
keystore.properties
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
|
||||
61
android/SIGNING_SETUP.md
Normal file
61
android/SIGNING_SETUP.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Android App Signing Setup
|
||||
|
||||
## Why This Matters
|
||||
Android requires apps to be signed with the same key for updates to work. Without proper signing, users cannot update your app - they must uninstall and reinstall, losing all data.
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
### 1. Create a Keystore (if you don't have one)
|
||||
|
||||
Run this command in the `android/` directory:
|
||||
|
||||
```bash
|
||||
keytool -genkey -v -keystore paarrot-release.keystore -alias paarrot -keyalg RSA -keysize 2048 -validity 10000
|
||||
```
|
||||
|
||||
You'll be asked for:
|
||||
- Keystore password (remember this!)
|
||||
- Key password (remember this!)
|
||||
- Your name, organization, etc.
|
||||
|
||||
**IMPORTANT**: Back up this keystore file and remember the passwords! If you lose either, you cannot update your app.
|
||||
|
||||
### 2. Create keystore.properties
|
||||
|
||||
Copy the example file:
|
||||
|
||||
```bash
|
||||
cp keystore.properties.example keystore.properties
|
||||
```
|
||||
|
||||
Then edit `keystore.properties` and fill in:
|
||||
- `storeFile`: path to your keystore (e.g., `paarrot-release.keystore`)
|
||||
- `storePassword`: the keystore password you set
|
||||
- `keyAlias`: the alias (e.g., `paarrot`)
|
||||
- `keyPassword`: the key password you set
|
||||
|
||||
### 3. Verify
|
||||
|
||||
The file `keystore.properties` should be gitignored (check `.gitignore`).
|
||||
|
||||
### 4. Build
|
||||
|
||||
Now your release builds will be properly signed:
|
||||
|
||||
```bash
|
||||
cd android
|
||||
./gradlew assembleRelease
|
||||
```
|
||||
|
||||
The signed APK will be in: `app/build/outputs/apk/release/`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Updates not installing"
|
||||
- You're using a different keystore than the original APK
|
||||
- Solution: Use the same keystore that was used for the first release
|
||||
|
||||
### "keystore.properties not found"
|
||||
- Normal for debug builds
|
||||
- Only needed for release builds
|
||||
- Create the file following step 2 above
|
||||
@@ -1,9 +1,28 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
// Load keystore properties
|
||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.paarrot.app"
|
||||
compileSdk = rootProject.ext.compileSdkVersion
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.paarrot.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
@@ -21,6 +40,9 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
applicationVariants.all { variant ->
|
||||
|
||||
@@ -47,6 +47,15 @@
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".PushPingReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="org.unifiedpush.android.connector.MESSAGE" />
|
||||
<action android:name="com.paarrot.app.ACTION_PUSH_PING" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
<!-- Permissions -->
|
||||
|
||||
@@ -3,34 +3,15 @@ package com.paarrot.app
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
|
||||
/**
|
||||
* Restarts [MatrixSyncService] after the device boots, using credentials
|
||||
* previously persisted by [SyncServicePlugin].
|
||||
* Triggers a one-shot sync fetch after boot if credentials exist.
|
||||
*/
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action != Intent.ACTION_BOOT_COMPLETED) return
|
||||
|
||||
val prefs = context.getSharedPreferences(SyncServicePlugin.PREFS, Context.MODE_PRIVATE)
|
||||
val homeserver = prefs.getString(MatrixSyncService.EXTRA_HOMESERVER, null) ?: return
|
||||
val token = prefs.getString(MatrixSyncService.EXTRA_TOKEN, null) ?: return
|
||||
val userId = prefs.getString(MatrixSyncService.EXTRA_USER_ID, null) ?: ""
|
||||
val deviceId = prefs.getString(MatrixSyncService.EXTRA_DEVICE_ID, null) ?: ""
|
||||
|
||||
val serviceIntent = Intent(context, MatrixSyncService::class.java).apply {
|
||||
putExtra(MatrixSyncService.EXTRA_HOMESERVER, homeserver)
|
||||
putExtra(MatrixSyncService.EXTRA_TOKEN, token)
|
||||
putExtra(MatrixSyncService.EXTRA_USER_ID, userId)
|
||||
putExtra(MatrixSyncService.EXTRA_DEVICE_ID, deviceId)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(serviceIntent)
|
||||
} else {
|
||||
context.startService(serviceIntent)
|
||||
}
|
||||
MatrixSyncService.requestSyncFetch(context, "boot_completed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.json.JSONObject
|
||||
@@ -25,12 +23,10 @@ import java.net.URL
|
||||
import java.net.URLEncoder
|
||||
|
||||
/**
|
||||
* Persistent ForegroundService that maintains a Matrix /sync long-poll loop,
|
||||
* showing native notifications for new messages when the main app process is alive
|
||||
* but the UI is not in the foreground, and when the app has been swiped away.
|
||||
* ForegroundService that performs a short, one-shot Matrix /sync fetch.
|
||||
*
|
||||
* Start via [SyncServicePlugin]. Credentials are persisted in SharedPreferences
|
||||
* so [BootReceiver] can restart it after a device reboot.
|
||||
* This service is wake-triggered by push pings (UnifiedPush/FCM bridge) and
|
||||
* then fetches message content from Matrix before posting local notifications.
|
||||
*/
|
||||
class MatrixSyncService : Service() {
|
||||
|
||||
@@ -57,13 +53,20 @@ class MatrixSyncService : Service() {
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
val triggerReason = intent?.getStringExtra(EXTRA_TRIGGER_REASON) ?: "unknown"
|
||||
startForeground(NOTIF_ID_STATUS, buildStatusNotification())
|
||||
|
||||
serviceScope.launch {
|
||||
runSyncLoop(homeserver, token, userId)
|
||||
try {
|
||||
runSingleSyncFetch(homeserver, token, userId)
|
||||
Log.d(TAG, "One-shot sync completed (reason=$triggerReason)")
|
||||
} finally {
|
||||
stopForegroundCompat()
|
||||
stopSelf(startId)
|
||||
}
|
||||
}
|
||||
|
||||
return START_STICKY
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -71,12 +74,11 @@ class MatrixSyncService : Service() {
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
private suspend fun runSyncLoop(homeserver: String, token: String, userId: String) {
|
||||
private suspend fun runSingleSyncFetch(homeserver: String, token: String, userId: String) {
|
||||
val prefs = applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
var since = prefs.getString(KEY_SINCE, null)
|
||||
var isFirstSync = since == null
|
||||
val since = prefs.getString(KEY_SINCE, null)
|
||||
val isFirstSync = since == null
|
||||
|
||||
while (serviceScope.isActive) {
|
||||
try {
|
||||
val url = buildSyncUrl(homeserver.trimEnd('/'), since)
|
||||
val (responseCode, body) = doHttpGet(url, token)
|
||||
@@ -92,23 +94,24 @@ class MatrixSyncService : Service() {
|
||||
if (!isFirstSync && !appInForeground) {
|
||||
processRoomEvents(json, userId)
|
||||
}
|
||||
isFirstSync = false
|
||||
since = nextBatch
|
||||
}
|
||||
}
|
||||
401, 403 -> {
|
||||
Log.w(TAG, "Auth error $responseCode — stopping sync")
|
||||
stopSelf()
|
||||
return
|
||||
Log.w(TAG, "Auth error $responseCode — clearing credentials")
|
||||
applicationContext
|
||||
.getSharedPreferences(SyncServicePlugin.PREFS, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.clear()
|
||||
.apply()
|
||||
}
|
||||
else -> {
|
||||
Log.w(TAG, "Sync fetch failed with HTTP $responseCode")
|
||||
}
|
||||
else -> delay(BACKOFF_ERRS_MS)
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Sync error: ${e.message}")
|
||||
delay(BACKOFF_ERRS_MS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +119,7 @@ class MatrixSyncService : Service() {
|
||||
val filter = """{"room":{"timeline":{"limit":10,"types":["m.room.message"]},"state":{"types":[]},"account_data":{"types":[]},"ephemeral":{"types":[]}},"account_data":{"types":[]},"presence":{"types":[]}}"""
|
||||
val encodedFilter = URLEncoder.encode(filter, "UTF-8")
|
||||
val sinceParam = if (since != null) "&since=${URLEncoder.encode(since, "UTF-8")}" else ""
|
||||
return "$base/_matrix/client/v3/sync?timeout=30000&filter=$encodedFilter$sinceParam"
|
||||
return "$base/_matrix/client/v3/sync?timeout=12000&filter=$encodedFilter$sinceParam"
|
||||
}
|
||||
|
||||
private suspend fun doHttpGet(urlString: String, token: String): Pair<Int, String?> =
|
||||
@@ -203,12 +206,21 @@ class MatrixSyncService : Service() {
|
||||
return NotificationCompat.Builder(this, CHANNEL_STATUS)
|
||||
.setSmallIcon(R.drawable.ic_stat_paarrot)
|
||||
.setContentTitle("Paarrot")
|
||||
.setContentText("Connected")
|
||||
.setContentText("Checking for new messages")
|
||||
.setPriority(NotificationCompat.PRIORITY_MIN)
|
||||
.setOngoing(true)
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun stopForegroundCompat() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
stopForeground(true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ensureMessageChannel(nm: NotificationManager) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(
|
||||
@@ -225,15 +237,52 @@ class MatrixSyncService : Service() {
|
||||
const val EXTRA_TOKEN = "access_token"
|
||||
const val EXTRA_USER_ID = "user_id"
|
||||
const val EXTRA_DEVICE_ID = "device_id"
|
||||
const val EXTRA_TRIGGER_REASON = "trigger_reason"
|
||||
const val PREFS = "matrix_sync_prefs"
|
||||
const val KEY_SINCE = "since_token"
|
||||
private const val KEY_LAST_WAKE_MS = "last_wake_ms"
|
||||
private const val NOTIF_ID_STATUS = 1001
|
||||
private const val CHANNEL_STATUS = "sync_status"
|
||||
private const val CHANNEL_MESSAGES = "messages"
|
||||
private const val BACKOFF_ERRS_MS = 10_000L
|
||||
private const val MIN_WAKE_INTERVAL_MS = 7_500L
|
||||
const val ACTION_PUSH_PING = "com.paarrot.app.ACTION_PUSH_PING"
|
||||
|
||||
/** Set by [SyncServicePlugin] — true when the Capacitor WebView UI is visible. */
|
||||
@Volatile
|
||||
var appInForeground = false
|
||||
|
||||
/**
|
||||
* Starts a one-shot sync fetch if credentials are available and the call is not rate-limited.
|
||||
*/
|
||||
fun requestSyncFetch(context: Context, reason: String) {
|
||||
val credsPrefs = context.getSharedPreferences(SyncServicePlugin.PREFS, Context.MODE_PRIVATE)
|
||||
val homeserver = credsPrefs.getString(EXTRA_HOMESERVER, null) ?: return
|
||||
val token = credsPrefs.getString(EXTRA_TOKEN, null) ?: return
|
||||
val userId = credsPrefs.getString(EXTRA_USER_ID, null) ?: ""
|
||||
val deviceId = credsPrefs.getString(EXTRA_DEVICE_ID, null) ?: ""
|
||||
|
||||
val syncPrefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||
val now = System.currentTimeMillis()
|
||||
val lastWake = syncPrefs.getLong(KEY_LAST_WAKE_MS, 0L)
|
||||
if (now - lastWake < MIN_WAKE_INTERVAL_MS) {
|
||||
Log.d(TAG, "Skipping wake: rate-limited ($reason)")
|
||||
return
|
||||
}
|
||||
syncPrefs.edit().putLong(KEY_LAST_WAKE_MS, now).apply()
|
||||
|
||||
val intent = Intent(context, MatrixSyncService::class.java).apply {
|
||||
putExtra(EXTRA_HOMESERVER, homeserver)
|
||||
putExtra(EXTRA_TOKEN, token)
|
||||
putExtra(EXTRA_USER_ID, userId)
|
||||
putExtra(EXTRA_DEVICE_ID, deviceId)
|
||||
putExtra(EXTRA_TRIGGER_REASON, reason)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(intent)
|
||||
} else {
|
||||
context.startService(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.paarrot.app
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
/**
|
||||
* Receives tiny push wake pings and triggers one Matrix fetch.
|
||||
*
|
||||
* - `org.unifiedpush.android.connector.MESSAGE` supports UnifiedPush distributors.
|
||||
* - [MatrixSyncService.ACTION_PUSH_PING] is an app-local fallback action
|
||||
* that other bridges (e.g., FCM service) can emit.
|
||||
*/
|
||||
class PushPingReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val reason = when (intent.action) {
|
||||
"org.unifiedpush.android.connector.MESSAGE" -> "unifiedpush_ping"
|
||||
MatrixSyncService.ACTION_PUSH_PING -> "app_push_ping"
|
||||
else -> return
|
||||
}
|
||||
|
||||
MatrixSyncService.requestSyncFetch(context, reason)
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.paarrot.app
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import com.getcapacitor.JSObject
|
||||
import com.getcapacitor.Plugin
|
||||
import com.getcapacitor.PluginCall
|
||||
@@ -13,19 +12,16 @@ import com.getcapacitor.annotation.CapacitorPlugin
|
||||
* Capacitor plugin that controls [MatrixSyncService] from JS.
|
||||
*
|
||||
* JS API:
|
||||
* - `start({ homeserverUrl, accessToken, userId, deviceId })` — start/update sync service
|
||||
* - `stop()` — stop sync service and clear persisted credentials
|
||||
* - `start({ homeserverUrl, accessToken, userId, deviceId })` — persist/update sync credentials
|
||||
* - `triggerPing({ reason })` — force a one-shot fetch (for testing/manual wake)
|
||||
* - `stop()` — clear persisted credentials and stop any in-flight fetch
|
||||
* - `setAppForeground({ foreground })` — tell the service whether the app UI is visible
|
||||
* - `getStatus()` — returns `{ running: boolean }`
|
||||
*/
|
||||
@CapacitorPlugin(name = "MatrixBackgroundSync")
|
||||
class SyncServicePlugin : Plugin() {
|
||||
|
||||
/**
|
||||
* Starts the [MatrixSyncService] with the provided Matrix credentials.
|
||||
* Persists credentials in SharedPreferences so [BootReceiver] can restart
|
||||
* the service after a device reboot.
|
||||
*/
|
||||
/** Persists Matrix credentials used later by push-triggered sync fetches. */
|
||||
@PluginMethod
|
||||
fun start(call: PluginCall) {
|
||||
val homeserver = call.getString("homeserverUrl")
|
||||
@@ -42,19 +38,14 @@ class SyncServicePlugin : Plugin() {
|
||||
.putString(MatrixSyncService.EXTRA_DEVICE_ID, deviceId)
|
||||
.apply()
|
||||
|
||||
val intent = Intent(context, MatrixSyncService::class.java).apply {
|
||||
putExtra(MatrixSyncService.EXTRA_HOMESERVER, homeserver)
|
||||
putExtra(MatrixSyncService.EXTRA_TOKEN, token)
|
||||
putExtra(MatrixSyncService.EXTRA_USER_ID, userId)
|
||||
putExtra(MatrixSyncService.EXTRA_DEVICE_ID, deviceId)
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(intent)
|
||||
} else {
|
||||
context.startService(intent)
|
||||
call.resolve()
|
||||
}
|
||||
|
||||
/** Manually triggers a one-shot sync fetch (mainly for diagnostics/testing). */
|
||||
@PluginMethod
|
||||
fun triggerPing(call: PluginCall) {
|
||||
val reason = call.getString("reason") ?: "manual_plugin_ping"
|
||||
MatrixSyncService.requestSyncFetch(context, reason)
|
||||
call.resolve()
|
||||
}
|
||||
|
||||
|
||||
14
android/keystore.properties.example
Normal file
14
android/keystore.properties.example
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copy this file to keystore.properties and fill in your actual values
|
||||
# NEVER commit keystore.properties to git!
|
||||
|
||||
# Path to your keystore file (relative to android/ directory)
|
||||
storeFile=paarrot-release.keystore
|
||||
|
||||
# Keystore password
|
||||
storePassword=your_keystore_password_here
|
||||
|
||||
# Key alias
|
||||
keyAlias=paarrot
|
||||
|
||||
# Key password
|
||||
keyPassword=your_key_password_here
|
||||
2
cinny
2
cinny
Submodule cinny updated: 0659f3c1b0...7b69ed6df8
@@ -1,8 +1,3 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@capacitor/android": "8.3.0",
|
||||
"@capacitor/cli": "8.3.0",
|
||||
"@capacitor/core": "8.3.0",
|
||||
"@capacitor/local-notifications": "8.0.2"
|
||||
}
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -419,9 +419,9 @@ function MessageNotifications() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the native Android background sync service on login, keeps it
|
||||
* Configures native Android push-ping background sync on login, keeps it
|
||||
* informed of foreground state so it doesn't double-fire notifications,
|
||||
* and stops it cleanly on unmount (logout).
|
||||
* and clears it cleanly on unmount (logout).
|
||||
* Only active on Android Capacitor builds.
|
||||
*/
|
||||
function BackgroundSyncSetup() {
|
||||
|
||||
@@ -2,14 +2,16 @@ import { Capacitor, registerPlugin } from '@capacitor/core';
|
||||
import type { MatrixClient } from 'matrix-js-sdk';
|
||||
|
||||
interface MatrixBackgroundSyncPlugin {
|
||||
/** Start the background sync service with the given Matrix credentials. */
|
||||
/** Persist credentials used by push-triggered one-shot sync fetches. */
|
||||
start(options: {
|
||||
homeserverUrl: string;
|
||||
accessToken: string;
|
||||
userId: string;
|
||||
deviceId: string;
|
||||
}): Promise<void>;
|
||||
/** Stop the background sync service and clear persisted credentials. */
|
||||
/** Trigger a one-shot fetch as if a push ping arrived. */
|
||||
triggerPing(options: { reason?: string }): Promise<void>;
|
||||
/** Stop any in-flight fetch and clear persisted credentials. */
|
||||
stop(): Promise<void>;
|
||||
/**
|
||||
* Notify the service whether the app UI is visible.
|
||||
@@ -28,9 +30,8 @@ export const isBackgroundSyncSupported = (): boolean =>
|
||||
Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android';
|
||||
|
||||
/**
|
||||
* Starts the native Matrix background sync service.
|
||||
* Reads credentials directly from the active MatrixClient.
|
||||
* Safe to call on every login — the service is idempotent.
|
||||
* Persists Matrix credentials for Android push-ping wake handling.
|
||||
* Safe to call on every login.
|
||||
* @param mx Authenticated Matrix client
|
||||
*/
|
||||
export const startBackgroundSync = async (mx: MatrixClient): Promise<void> => {
|
||||
@@ -53,15 +54,29 @@ export const startBackgroundSync = async (mx: MatrixClient): Promise<void> => {
|
||||
userId,
|
||||
deviceId: deviceId ?? '',
|
||||
});
|
||||
console.log('[BackgroundSync] Service started');
|
||||
console.log('[BackgroundSync] Push wake credentials configured');
|
||||
} catch (err) {
|
||||
console.warn('[BackgroundSync] Failed to start:', err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stops the native Matrix background sync service.
|
||||
* Call on logout so the service stops and credentials are wiped.
|
||||
* Manually triggers a one-shot native fetch.
|
||||
* Useful for diagnostics and bridge testing.
|
||||
*/
|
||||
export const triggerBackgroundSyncPing = async (reason?: string): Promise<void> => {
|
||||
if (!isBackgroundSyncSupported()) return;
|
||||
|
||||
try {
|
||||
await MatrixBackgroundSync.triggerPing({ reason });
|
||||
} catch (err) {
|
||||
console.warn('[BackgroundSync] triggerPing failed:', err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stops native background sync handling and clears persisted credentials.
|
||||
* Call on logout.
|
||||
*/
|
||||
export const stopBackgroundSync = async (): Promise<void> => {
|
||||
if (!isBackgroundSyncSupported()) return;
|
||||
|
||||
1063
package-lock.json
generated
1063
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@@ -1,22 +1,19 @@
|
||||
{
|
||||
"name": "paarrot",
|
||||
"version": "4.11.83",
|
||||
"version": "4.11.88",
|
||||
"description": "Paarrot - A Matrix client based on Cinny",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"android:prepare": "node scripts/apply-overlay.mjs && cd cinny && npm install && npm run build && npx cap sync android",
|
||||
"android:patch-settings:linux": "sed -i 's|../node_modules/|../cinny/node_modules/|g' android/capacitor.settings.gradle",
|
||||
"android:restore": "node scripts/restore-cinny.mjs",
|
||||
"android:open": "cd cinny && npx cap open android",
|
||||
"android:run": "cd cinny && npx cap run android",
|
||||
"android:apk": "npm run android:prepare && cd cinny/android && gradlew.bat assembleDebug && cd ../.. && node scripts/restore-cinny.mjs",
|
||||
"android:apk:linux": "npm run android:prepare && npm run android:patch-settings:linux && cd cinny/android && ./gradlew assembleDebug && cd ../.. && node scripts/restore-cinny.mjs",
|
||||
"android:apk:release": "npm run android:prepare && cd cinny/android && gradlew.bat assembleRelease && cd ../.. && node scripts/restore-cinny.mjs",
|
||||
"android:apk:release:linux": "npm run android:prepare && npm run android:patch-settings:linux && cd cinny/android && ./gradlew assembleRelease && cd ../.. && node scripts/restore-cinny.mjs",
|
||||
"android:aab": "npm run android:prepare && cd cinny/android && gradlew.bat bundleRelease && cd ../.. && node scripts/restore-cinny.mjs",
|
||||
"android:aab:linux": "npm run android:prepare && npm run android:patch-settings:linux && cd cinny/android && ./gradlew bundleRelease && cd ../.. && node scripts/restore-cinny.mjs"
|
||||
"apply-overlay": "node scripts/apply-overlay.mjs",
|
||||
"android:prepare": "cd cinny && npm run build && cd .. && npx cap sync android",
|
||||
"android:open": "npx cap open android",
|
||||
"android:run": "npx cap run android",
|
||||
"android:apk": "npm run apply-overlay && npm run android:prepare && cd android && gradlew.bat assembleDebug",
|
||||
"android:apk:release": "npm run apply-overlay && npm run android:prepare && cd android && gradlew.bat assembleRelease",
|
||||
"android:apk:linux": "cd cinny && npm run build && cd .. && npx cap sync android && cd android && ./gradlew assembleDebug",
|
||||
"android:aab": "npm run apply-overlay && npm run android:prepare && cd android && gradlew.bat bundleRelease"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
@@ -24,6 +21,12 @@
|
||||
"email": "mates.media@users.noreply.github.com"
|
||||
},
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@capacitor/android": "8.3.0",
|
||||
"@capacitor/cli": "8.3.0",
|
||||
"@capacitor/core": "8.3.0",
|
||||
"@capacitor/local-notifications": "8.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-fetch": "3.3.2",
|
||||
"png2icons": "2.0.1",
|
||||
|
||||
Reference in New Issue
Block a user