Skip to content

Commit

Permalink
Merge branch 'develop' into USH-1097
Browse files Browse the repository at this point in the history
  • Loading branch information
Mh-Asmi committed May 17, 2024
2 parents 0d878da + 463e2e4 commit 4594bd6
Show file tree
Hide file tree
Showing 27 changed files with 397 additions and 91 deletions.
56 changes: 56 additions & 0 deletions .github/actions/release-tar/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Release tar'
description: Build and upload a tarball to GitHub releases
# inputs:
# version:
# description: 'Version to release'
# required: true

runs:
using: "composite"

steps:
- name: Set version number
id: version
shell: bash
run: |
RELEASE_VERSION="${GITHUB_REF##*/}";
RELEASE_FILE="ushahidi-platform-bundle-${RELEASE_VERSION}.tar.gz"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "RELEASE_FILE=${RELEASE_FILE}" >> $GITHUB_OUTPUT
- name: Build image
uses: docker/build-push-action@v3
with:
context: .
push: false
load: true
tags: local/platform:latest
build-args: |
GIT_COMMIT_ID=${{ github.sha }}
GIT_BUILD_REF=${{ github.head_ref }}
- name: Prepare folder
shell: bash
run:
mkdir -p tmp/out

- name: Create release file
uses: addnab/docker-run-action@v3
with:
image: local/platform:latest
run: docker/release.sh ${{ steps.version.outputs.RELEASE_VERSION }}
options: |
--entrypoint /bin/bash
-v ${{ github.workspace }}/tmp/out:/var/www/build
- name: List release content
shell: bash
run: |
tar -tvf tmp/out/${{ steps.version.outputs.RELEASE_FILE }};
- name: Upload tarball
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
tmp/out/${{ steps.version.outputs.RELEASE_FILE }}
20 changes: 12 additions & 8 deletions .github/workflows/test-and-ship.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- pull_request

env:
MYSQL_ROOT_PASSWORD: root
MARIADB_ROOT_PASSWORD: root

jobs:
test:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
port=${DB_PORT}
database=mysql
user=root
password=${MYSQL_ROOT_PASSWORD}
password=${MARIADB_ROOT_PASSWORD}
EOF
mysql -e "SELECT version();" ;
Expand Down Expand Up @@ -92,12 +92,12 @@ jobs:
services:
mysql:
image: mysql:5.7
image: mariadb:10.11
env:
MYSQL_DATABASE: ushahidi
MYSQL_USER: ushahidi
MYSQL_PASSWORD: ushahidi
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
MARIADB_DATABASE: ushahidi
MARIADB_USER: ushahidi
MARIADB_PASSWORD: ushahidi
MARIADB_ROOT_PASSWORD: ${{ env.MARIADB_ROOT_PASSWORD }}
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping -h localhost"
Expand All @@ -114,7 +114,7 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand Down Expand Up @@ -161,3 +161,7 @@ jobs:
GIT_BUILD_REF=${{ github.head_ref }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push release tar file
uses: ./.github/actions/release-tar
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
10 changes: 5 additions & 5 deletions codeship-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ deploy:


mysql/base: &_mysql_base
image: mysql:5.7
image: mariadb:10.11
environment:
- MYSQL_DATABASE=ushahidi
- MYSQL_USER=ushahidi
- MYSQL_PASSWORD=ushahidi
- MYSQL_ROOT_PASSWORD=root
- MARIADB_DATABASE=ushahidi
- MARIADB_USER=ushahidi
- MARIADB_PASSWORD=ushahidi
- MARIADB_ROOT_PASSWORD=root
mysql-7.2:
<<: *_mysql_base
mysql-7.3:
Expand Down
4 changes: 4 additions & 0 deletions config/data-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
'gmail' => false,
'mteja' => false,
'africastalking' => false,
'httpsms' => false,
'infobip' => false,
],

'authenticable-providers' => [
Expand All @@ -30,6 +32,8 @@
'incoming_security' => '',
'incoming_username' => '',
'incoming_password' => '',
'incoming_unread_only' => 'Unread',
'incoming_last_uid' => '0'
],
'twilio' => [],
'smssync' => [],
Expand Down
4 changes: 2 additions & 2 deletions config/features.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
'gmail' => false,
'mteja' => false,
'africastalking' => false,
'httpsms' => false,
'infobip' => false,
'httpsms' => true,
'infobip' => true,
],

// Client limits
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php


use Phinx\Migration\AbstractMigration;

class AddMissingAdminPermissions extends AbstractMigration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Manage Users')");

$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Manage Posts')");

$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Manage Settings')");

$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Bulk Data Import and Export')");

$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Edit their own posts')");

$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Delete Posts')");

$this->execute("INSERT INTO `roles_permissions` (`role`, `permission`)
VALUES ('admin', 'Delete Their Own Posts')");
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Manage Users'");

$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Manage Posts'");

$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Manage Settings'");

$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Bulk Data Import and Export'");

$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Edit their own posts'");

$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Delete Posts'");

$this->execute("DELETE FROM roles_permissions
WHERE permission = 'Delete Their Own Posts'");
}
}
13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
version: "2"
services:
mysql:
platform: linux/amd64
image: mysql:5.7
image: mariadb:10.11
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ushahidi
MYSQL_USER: ushahidi
MYSQL_PASSWORD: ushahidi
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: ushahidi
MARIADB_USER: ushahidi
MARIADB_PASSWORD: ushahidi
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
# mysql 8.0
# - --default-authentication-plugin=mysql_native_password
ports:
- "33061:3306"
redis:
Expand Down
55 changes: 55 additions & 0 deletions docker/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# if someone invokes this with bash
set -e

# build release tarball
usage() {
echo usage: $0 VERSION
exit 2
}

test $# -eq 1 || usage
VERSION=$1
CWD=$(pwd)

# Install composer dependencies (with autoload file generation enabled)
composer install --no-scripts;

TMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t platform-build)
WORK_DIR=$TMP_DIR/ushahidi-platform-bundle-${VERSION}
mkdir $WORK_DIR

if [ -z "$DEST_DIR" ]; then
DEST_DIR="${CWD}/build"
fi

echo "Copy to temp dir"
cp -R ./ $WORK_DIR

# Tar it up.
echo "Building tarball"
if [ ! -d "$DEST_DIR" ]; then
mkdir -p "$DEST_DIR"
fi
TARFILE="${DEST_DIR}/ushahidi-platform-bundle-${VERSION}.tar"

tar -C $TMP_DIR -cf $TARFILE \
--exclude 'build' \
--exclude 'docs' \
--exclude 'storage/logs/*' \
--exclude '.travis.yml' \
--exclude '.vagrant' \
--exclude 'tmp' \
--exclude '.env' \
--exclude '.env.travis' \
--exclude '.git' \
--exclude '.gitbook' \
ushahidi-platform-bundle-${VERSION}/

gzip -f $TARFILE
echo "Release tarball: ${TARFILE}.gz"

ls -la ${TARFILE}.gz

rm -rf $TMP_DIR
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* zip
* Composer for PHP package management \( [https://getcomposer.org](https://getcomposer.org) \)
* Nginx version 1.10.x **\(Note: you can technically use apache, but this instructions will provide specific steps for Nginx only\)**
* MySQL server 5.7.x
* MariaDB server 10.11
* Node.js v10.x or higher
* Redis v3.2
* Cron daemon
Expand Down
2 changes: 1 addition & 1 deletion src/Ushahidi/Addons/HttpSMS/HttpSMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Ushahidi\Addons\HttpSMS;

/**
* Infobip Data Source
* HttpSMS Data Source
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Addons\HttpSMS
Expand Down
2 changes: 1 addition & 1 deletion src/Ushahidi/Addons/Infobip/InfobipServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function send($to, $message, $title = "", $contact_type = null, $message_
if ($content['status'] == 'success') {
return [MessageStatus::SENT, $content['data']['id']];
} else {
Log::error('HttpSMS: Failed to send message: ' . $content['message']);
Log::error('Infobip: Failed to send message: ' . $content['message']);
return [MessageStatus::FAILED, false];
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Ushahidi/Addons/Mteja/ShortMessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ class ShortMessageController extends DataSourceController
public function handleRequest(Request $request)
{
// Remove Non-Numeric characters because that's what the DB has
$from = preg_replace("/[^0-9,+.]/", "", $request->input('from'));
$from = preg_replace("/[^0-9,+.]/", "", $request->input('customerNumber'));

$this->save([
'type' => MessageType::SMS,
'from' => $from,
'contact_type' => Contact::PHONE,
'message' => $request->input('text'),
'to' => $request->input('to'),
'to' => $request->input('virtualNumber'),
'title' => null,
'datetime' => null,
'data_source_message_id' => "mteja-" . UUID::uuid4()->toString(),
'datetime' => $request->input('date'),
'data_source_message_id' => $request->input('atSmsId', UUID::uuid4()->toString()),
'data_source' => 'mteja',
'additional_data' => [
'fieldName' => $request->input('fieldName'),
'questionText' => $request->input('questionText')
'appId' => $request->input('appId'),
// 'questionText' => $request->input('questionText')
]
]);

Expand Down
3 changes: 2 additions & 1 deletion src/Ushahidi/DataSource/DataSourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ protected function createEmailSource(array $config)
return new Email\Email(
$config,
app('mailer'),
app(MessageRepository::class)
app(MessageRepository::class),
$this->configRepo
);
}

Expand Down

0 comments on commit 4594bd6

Please sign in to comment.