Skip to content

Commit

Permalink
Backport hot fixes to develop branch (#4684)
Browse files Browse the repository at this point in the history
* Update UpdatePostCommand.php (#4672)

* Update UpdatePostCommand.php

Since we're making an update, there's no reason to updating the created column.

* fix: ensure Timestamp is correct before updating entity

* chore: use laravel config to retrieve settings in V5 config handler

* refactor: update eloquent repo for category

* chore: work on the places we use the data source label

* chore: fix lint in EloquentPostRepository

* test: resolve failing test for V3 endpoints

* chore: update create post command to record post source

* fix lint

* fix: fallback to null when user attribute value is undefined

* fix config data permission

* fix the issue of returned fromated created value

* Update usersetting to accept config value as array

---------

Co-authored-by: Wisdom Ebong <[email protected]>
Co-authored-by: Wisdom Ebong <[email protected]>
Co-authored-by: Mh-Asmi <[email protected]>
Co-authored-by: ushahidlee <[email protected]>
  • Loading branch information
5 people authored Jan 8, 2024
1 parent 9f3e368 commit 92c485f
Show file tree
Hide file tree
Showing 23 changed files with 355 additions and 35 deletions.
1 change: 1 addition & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Ushahidi\Modules\V5\Repository\Apikey;
use Ushahidi\Modules\V5\Repository\Webhook;
use Ushahidi\Modules\V5\Repository\HXL;
use Jenssegers\Agent\Agent;

class AppServiceProvider extends ServiceProvider
{
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"guzzlehttp/guzzle": "^6.5|^7.0.1",
"intercom/intercom-php": "^4.4",
"ircmaxell/password-compat": "^1.0.4",
"jenssegers/agent": "^2.6",
"laravel/framework": "^8.0",
"laravel/passport": "^10.0",
"laravel/tinker": "^2.5",
Expand Down
199 changes: 198 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Phinx\Migration\AbstractMigration;

class AddMetadataToPostsTable extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->table('posts')
->addColumn('metadata', 'json', [
'null' => true,
])
->update();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Phinx\Migration\AbstractMigration;

class AddSourceToPostsTable extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->table('posts')
->addColumn('source', 'text', [
'null' => true,
'after' => 'status'
])
->update();
}
}
8 changes: 1 addition & 7 deletions src/Ushahidi/Authzn/GenericUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Contracts\Auth\Authenticatable as AuthContract;
use Laravel\Passport\HasApiTokens;
use Ushahidi\Contracts\Entity;
use Ushahidi\Core\Entity\User;

class GenericUser implements Entity, AuthContract
{
Expand Down Expand Up @@ -130,7 +129,7 @@ public function asArray()
*/
public function __get($key)
{
return $this->attributes[$key];
return $this->attributes[$key] ?? null;
}

/**
Expand Down Expand Up @@ -166,9 +165,4 @@ public function __unset($key)
{
unset($this->attributes[$key]);
}

public function generateEntityFromSelf(): User
{
return new User($this->attributes);
}
}
1 change: 1 addition & 0 deletions src/Ushahidi/Core/Entity/FormStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected function getDefinition()
'sms' => 'int',
'web' => 'int',
'twitter' => 'int',
'mobile' => 'int',
'email' => 'int'
],
];
Expand Down
6 changes: 6 additions & 0 deletions src/Ushahidi/Core/Entity/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Post extends StaticEntity
protected $source;
// When originating in an SMS message
protected $contact_id;

protected $metadata;

protected $data_source_message_id;

// StatefulData
Expand All @@ -57,6 +60,7 @@ protected function getDefaultData()
'type' => 'report',
'locale' => 'en_US',
'published_to' => [],
'metadata' => null,
];
}

Expand Down Expand Up @@ -109,6 +113,8 @@ protected function getDefinition()
'completed_stages'=> '*arrayInt',
'sets' => 'array',
'lock' => 'array',
'source' => 'string',
'metadata' => '*json',
'data_source_message_id' => 'string'
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ushahidi/Core/Entity/UserSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getDefinition()
'id' => 'int',
'user_id' => 'int',
'config_key' => 'string',
'config_value' => 'string',
// 'config_value' => 'string',
'created' => 'int',
'updated' => 'int',
];
Expand Down
Loading

0 comments on commit 92c485f

Please sign in to comment.