Skip to content

Commit

Permalink
Add SMS channel support via Infobip and HttpSMS addons (#4637)
Browse files Browse the repository at this point in the history
* wip: Add SMS channel support via Infobip and HttpSMS addons

- Moved Config files to the Laravel config directory
- Added Infobip DataSource supporting SMS channel
- Added HttpSMS DataSource supporting SMS channel
- Small changes to AfricasTalking and Mteja addons
- Adjusted V3 ConfigRepository to use the new config files

* chore: laravel package discovery for platform addons

* feat: support incoming sms channel  for httpsms and infobip  providers

* fix: phpcs lint issue

* chore: fix fetching enabled sources on the data source manager

* test: fix Receive message test

* chore: update features config file

* chore: update integration test
  • Loading branch information
webong authored Nov 1, 2023
1 parent 8126c02 commit 5c21626
Show file tree
Hide file tree
Showing 43 changed files with 1,436 additions and 1,147 deletions.
88 changes: 1 addition & 87 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Ushahidi\Core\Tool\SiteManager;
use Ushahidi\Addons\Mteja\MtejaSource;
use Ushahidi\Core\Tool\FeatureManager;
use Illuminate\Support\ServiceProvider;
use Ushahidi\Core\Tool\OhanzeeResolver;
use Ushahidi\Core\Usecase\Export\Job\PostCount;
use Ushahidi\Addons\AfricasTalking\AfricasTalkingSource;
use Ushahidi\Contracts\Repository\Entity\PostRepository;
use Ushahidi\Contracts\Repository\Entity\UserRepository;
use Ushahidi\Contracts\Repository\Entity\ConfigRepository;
use Ushahidi\Modules\V5\Models\Post\Post as PostModel;
use Ushahidi\Modules\V5\Repository\Category\CategoryRepository;
Expand Down Expand Up @@ -52,13 +47,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
/**
* For now this configuration is temporary,
* should be moved to an isolated place within the addon directory
*/
$this->app['datasources']->extend('africastalking', AfricasTalkingSource::class);

$this->app['datasources']->extend('mteja', MtejaSource::class);
}

/**
Expand Down Expand Up @@ -88,83 +76,9 @@ public function register()
return new OhanzeeResolver();
});

$this->registerServicesFromAura();

$this->registerFeatures();
}

public function registerServicesFromAura()
{
$this->app->singleton(UsecaseFactory::class, function ($app) {
// Just return it from AuraDI
return service('factory.usecase');
});

$this->app->singleton(UserRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.user');
});

$this->app->singleton(MessageRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.message');
});

$this->app->singleton(ConfigRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.config');
});

$this->app->singleton(ContactRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.contact');
});

$this->app->singleton(PostRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.post');
});

$this->app->singleton(ExportJobRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.export_job');
});

$this->app->singleton(ExportBatchRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.export_batch');
});

$this->app->singleton(TargetedSurveyStateRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.targeted_survey_state');
});

$this->app->singleton(FormAttributeRepository::class, function ($app) {
// Just return it from AuraDI
return service('repository.form_attribute');
});

$this->app->singleton(Verifier::class, function ($app) {
// Just return it from AuraDI
return service('tool.verifier');
});

$this->app->singleton(PostCount::class, function ($app) {
return service('factory.usecase')
// Override action
->get('export_jobs', 'post-count')
// Override authorizer
->setAuthorizer(service('authorizer.external_auth')); // @todo remove the need for this?
});

$this->app->singleton(Export::class, function ($app) {
return service('factory.usecase')
->get('posts_export', 'export')
->setAuthorizer(service('authorizer.export_job'));
});
}

public function registerFeatures()
{
$this->app->bind(CountryCodeRepository::class, EloquentCountryCodeRepository::class);
Expand Down
21 changes: 21 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@
App\Exceptions\Handler::class
);

/*
|--------------------------------------------------------------------------
| Extend Package Manifest
|--------------------------------------------------------------------------
|
| This script extends the package manifest to include packages that are
| not discovered by Laravel by default. This is useful for packages
| that are not installed via composer, but are still in the app.
| This is the case for the Ushahidi Platform Addons loaded via
| the Wikimedia Composer Merge Plugin.
|
*/

$app->extend(\Illuminate\Foundation\PackageManifest::class, function ($manifest) {
return new \Ushahidi\Core\LaravelPackageManifest(
$manifest->files,
$manifest->basePath,
$manifest->manifestPath
);
});

/*
|--------------------------------------------------------------------------
| Return The Application
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
}
],
"require": {
"php": ">=7.3 <7.4",
"abraham/twitteroauth": "^0.5.3",
"africastalking/africastalking": "^3.0",
"php": ">=7.3 <=7.4",
"asm89/stack-cors": "^2.1",
"doctrine/cache": "^1.6.2",
"doctrine/dbal": "^2.0",
Expand All @@ -36,18 +34,14 @@
"nyholm/psr7": "^1.5",
"ohanzee/database": "dev-namespaces",
"php-http/curl-client": "^2.2",
"php-opencloud/openstack": "^3.2",
"predis/predis": "~1.1",
"robmorgan/phinx": "~0.11.2",
"sentry/sentry-laravel": "^1.9|^2.11",
"symfony/event-dispatcher": "^5.4",
"symfony/psr-http-message-bridge": "^2.0",
"symm/gisconverter": "~1.0.5",
"twilio/sdk": "^5.15",
"ushahidi/gmail-support": "dev-mzima",
"ushahidi/kohana-validation": "dev-master",
"ushahidi/laravel-ckan-api": "dev-master",
"vonage/client": "^2.3",
"wikimedia/composer-merge-plugin": "^2.0",
"willdurand/negotiation": "^2.3"
},
Expand Down Expand Up @@ -80,6 +74,7 @@
"http",
"git"
],

"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
Expand Down Expand Up @@ -203,6 +198,12 @@
],
"snowboard-v5-serve": [
"snowboard http docs/api/v5/index.apib"
],
"safe-update-dev": [
"composer update --ignore-platform-req=php"
],
"safe-install-dev": [
"composer install --ignore-platform-req=php"
]
},
"minimum-stability": "dev",
Expand Down
Loading

0 comments on commit 5c21626

Please sign in to comment.