Skip to content

Commit

Permalink
Merge branch 'master' into fix-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudIO authored Oct 28, 2023
2 parents 2c536c4 + 44f7981 commit f641941
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 75 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/build-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ name: Audit 3rd Party Libs


on:
push:
branches:
- 'master'
schedule:
- cron: '0 9 * * 6'

env:
node_version: 18

jobs:
audit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['20.x']
steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
with:
# fetch full history so things like auto-changelog work properly
fetch-depth: 0
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v2-beta
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
node-version: ${{ matrix.node-version }}
cache: 'npm'
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: 'https://registry.npmjs.org'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration Tests
name: Build, Test and Package

on:
pull_request:
Expand All @@ -9,7 +9,7 @@ on:
- master

jobs:
Test:
test-n-package:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Build App
run: |
npm run build
npm run package
- name: Run Docker
run: |
Expand All @@ -72,4 +72,9 @@ jobs:
- name: Stop Docker
run: |
npm run ci-docker-test-down
- name: Upload zip file
uses: actions/upload-artifact@v3
with:
name: ChurchCRM-${{ steps.package-version.outputs.current-version}}
path: target/ChurchCRM-*.zip
39 changes: 0 additions & 39 deletions .github/workflows/package-build.yml

This file was deleted.

12 changes: 8 additions & 4 deletions .github/workflows/poeditor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ jobs:

Download:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['20.x']
steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
with:
# fetch full history so things like auto-changelog work properly
fetch-depth: 0
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v2-beta
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
node-version: ${{ matrix.node-version }}
cache: 'npm'
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: 'https://registry.npmjs.org'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
release-notes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Create Release Notes
uses: docker://decathlon/release-notes-generator-action:2.1.0
env:
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions src/ChurchCRM/utils/MiscUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public static function getRandomCache($baseCacheTime,$variability){
public static function getPhotoCacheExpirationTimestamp() {
$cacheLength = SystemConfig::getValue("iPhotoClientCacheDuration");
$cacheLength = MiscUtils::getRandomCache($cacheLength,0.5*$cacheLength);
//echo time() + $cacheLength;
//die();
return time() + $cacheLength ;
}

Expand Down
8 changes: 4 additions & 4 deletions src/api/routes/people/people-family.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

$app->group('/family/{familyId:[0-9]+}', function () use ($app) {
$app->get('/photo', function ($request, $response, $args) use ($app) {
$res = $app->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$photo = new Photo("Family", $args['familyId']);
return $res->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
return $response->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
});

$app->post('/photo', function ($request, $response, $args) {
Expand All @@ -33,9 +33,9 @@
})->add(new EditRecordsRoleAuthMiddleware());

$app->get('/thumbnail', function ($request, $response, $args) use ($app) {
$res = $app->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$photo = new Photo("Family", $args['familyId']);
return $res->write($photo->getThumbnailBytes())->withHeader('Content-type', $photo->getThumbnailContentType());
return $response->write($photo->getThumbnailBytes())->withHeader('Content-type', $photo->getThumbnailContentType());
});

$app->get('', function ($request, $response, $args) {
Expand Down
22 changes: 11 additions & 11 deletions src/api/routes/people/people-person.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
// This group does not load the person via middleware (to speed up the page loads)
$app->group('/person/{personId:[0-9]+}', function () use ($app) {

$app->get('/thumbnail', function ($request, $response, $args) use ($app) {
$res = $app->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$app->get('/thumbnail', function (Request $request, Response $response, array $args) use ($app) {
$this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$photo = new Photo("Person", $args['personId']);
return $res->write($photo->getThumbnailBytes())->withHeader('Content-type', $photo->getThumbnailContentType());
return $response->write($photo->getThumbnailBytes())->withHeader('Content-type', $photo->getThumbnailContentType());
});

$app->get('/photo', function ($request, $response, $args) use ($app) {
$res = $app->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$app->get('/photo', function (Request $request, Response $response, array $args) use ($app) {
$this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
$photo = new Photo("Person", $args['personId']);
return $res->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
return $response->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
});
});

$app->group('/person/{personId:[0-9]+}', function () use ($app) {

$app->get('', function ($request, $response, $args) {
$app->get('', function (Request $request, Response $response, array $args) {
$person = $request->getAttribute("person");
return $response->withHeader('Content-Type', 'application/json')->write($person->exportTo('JSON'));
});

$app->delete('', function ($request, $response, $args) {
$app->delete('', function (Request $request, Response $response, array $args) {
$person = $request->getAttribute("person");
if (AuthenticationManager::GetCurrentUser()->getId() == $person->getId()) {
return $response->withStatus(403, gettext("Can't delete yourself"));
Expand All @@ -45,18 +45,18 @@

$app->post('/role/{roleId:[0-9]+}', 'setPersonRoleAPI')->add(new EditRecordsRoleAuthMiddleware());

$app->post('/addToCart', function ($request, $response, $args) {
$app->post('/addToCart', function (Request $request, Response $response, array $args) {
Cart::AddPerson($args['personId']);
});

$app->post('/photo', function ($request, $response, $args) {
$app->post('/photo', function (Request $request, Response $response, array $args) {
$person = $request->getAttribute("person");
$input = (object)$request->getParsedBody();
$person->setImageFromBase64($input->imgBase64);
$response->withJson(["status" => "success"]);
})->add(new EditRecordsRoleAuthMiddleware());

$app->delete('/photo', function ($request, $response, $args) {
$app->delete('/photo', function (Request $request, Response $response, array $args) {
$person = $request->getAttribute("person");
return $response->withJson(['success' => $person->deletePhoto()]);
})->add(new DeleteRecordRoleAuthMiddleware());
Expand Down

0 comments on commit f641941

Please sign in to comment.