Skip to content

Commit

Permalink
Merge branch 'hotfix/encode-binary' into feature/fetch-extra-data
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Nov 30, 2024
2 parents 6676ceb + 66696a9 commit 117986e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/pull-request-from-branch-check.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Main Branch Protection

on:
pull_request:
branches:
- main
#on:
# pull_request:
# branches:
# - main

jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
run: |
if [[ ${GITHUB_HEAD_REF} != development ]] && [[ ${GITHUB_HEAD_REF} != documentation ]] && ! [[ ${GITHUB_HEAD_REF} =~ ^hotfix/ ]];
then
echo "Error: Pull request must come from 'development', 'documentation' or 'hotfix/' branch"
exit 1
fi
#jobs:
# check-branch:
# runs-on: ubuntu-latest
# steps:
# - name: Check branch
# run: |
# if [[ ${GITHUB_HEAD_REF} != development ]] && [[ ${GITHUB_HEAD_REF} != documentation ]] && ! [[ ${GITHUB_HEAD_REF} =~ ^hotfix/ ]];
# then
# echo "Error: Pull request must come from 'development', 'documentation' or 'hotfix/' branch"
# exit 1
# fi
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The OpenConnector Nextcloud app provides a ESB-framework to work together in an
- 🆓 Map and translate API calls
]]></description>
<version>0.1.16</version>
<version>0.1.20</version>
<licence>agpl</licence>
<category>integration</category>
<author mail="[email protected]" homepage="https://www.conduction.nl/">Conduction</author>
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version1Date20241111144800.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
&& $table->hasColumn('source_id') === true && $table->hasColumn('source_hash') === true
) {
$this->connection->executeQuery("
UPDATE openconnector_synchronization_contracts
UPDATE oc_openconnector_synchronization_contracts
SET origin_id = source_id, origin_hash = source_hash
WHERE source_id IS NOT NULL
");
Expand Down
5 changes: 4 additions & 1 deletion lib/Service/CallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public function call(

$time_end = microtime(true);

$body = $response->getBody()->getContents();

// Let create the data array
$data = [
'request' => [
Expand All @@ -263,7 +265,8 @@ public function call(
'size' => $response->getBody()->getSize(),
'remoteIp' => $response->getHeaderLine('X-Real-IP') ?: $response->getHeaderLine('X-Forwarded-For') ?: null,
'headers' => $response->getHeaders(),
'body' => $response->getBody()->getContents(),
'body' => mb_check_encoding(value: $body, encoding: 'UTF-8') !== false ? $body : base64_encode($body),
'encoding' => mb_check_encoding(value: $body, encoding: 'UTF-8') !== false ? 'UTF-8' : 'base64',
]
];

Expand Down
2 changes: 1 addition & 1 deletion lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ public function synchronizeContract(SynchronizationContract $synchronizationCont

// Let create a source hash for the object
$originHash = md5(serialize($object));
$synchronizationContract->setSourceLastChecked(new DateTime());

// Let's prevent pointless updates @todo account for omnidirectional sync, unless the config has been updated since last check then we do want to rebuild and check if the tagert object has changed
if ($originHash === $synchronizationContract->getOriginHash() && $synchronization->getUpdated() < $synchronizationContract->getSourceLastChecked()) {
Expand All @@ -322,6 +321,7 @@ public function synchronizeContract(SynchronizationContract $synchronizationCont
// The object has changed, oke let do mappig and bla die bla
$synchronizationContract->setOriginHash($originHash);
$synchronizationContract->setSourceLastChanged(new DateTime());
$synchronizationContract->setSourceLastChecked(new DateTime());

// Check if object adheres to conditions.
// Take note, JsonLogic::apply() returns a range of return types, so checking it with '=== false' or '!== true' does not work properly.
Expand Down
43 changes: 43 additions & 0 deletions lib/Settings/OpenConnectorAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace OCA\OpenConnector\Settings;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;

class OpenConnectorAdmin implements ISettings {
private IL10N $l;
private IConfig $config;

public function __construct(IConfig $config, IL10N $l) {
$this->config = $config;
$this->l = $l;
}

/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'mySetting' => $this->config->getSystemValue('open_connector_setting', true),
];

return new TemplateResponse('openconnector', 'settings/admin', $parameters, '');
}

public function getSection() {
return 'openconnector'; // Name of the previously created section.
}

/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 10;
}
}

0 comments on commit 117986e

Please sign in to comment.