Skip to content

Commit

Permalink
Merge pull request #1668 from bakaphp/development
Browse files Browse the repository at this point in the history
Release RC4
  • Loading branch information
kaioken committed Jul 15, 2024
2 parents d4afe37 + d354705 commit 1b8c8e2
Show file tree
Hide file tree
Showing 60 changed files with 1,306 additions and 196 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,5 @@ TEST_ZOHO_CLIENT_REFRESH_TOKEN=

TEST_SHOPIFY_API_KEY=
TEST_SHOPIFY_API_SECRET=
TEST_SHOPIFY_SHOP_URL=
TEST_SHOPIFY_SHOP_URL=
TEST_STRIPE_SECRET_KEY=
2 changes: 2 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
TEST_SHOPIFY_SHOP_URL: ${{ secrets.TEST_SHOPIFY_SHOP_URL }}
TEST_APPLE_LOGIN_TOKEN: ${{ secrets.TEST_APPLE_LOGIN_TOKEN }}
TEST_APOLLO_KEY: ${{ secrets.TEST_APOLLO_KEY }}
TEST_STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}

strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
MEILISEARCH_KEY: masterKey
SCOUT_QUEUE: false
#APP_DEBUG: true

#third party integration
TEST_ZOHO_CLIENT_ID: ${{ secrets.TEST_ZOHO_CLIENT_ID }}
TEST_ZOHO_CLIENT_SECRET: ${{ secrets.TEST_ZOHO_CLIENT_SECRET }}
Expand All @@ -66,6 +67,7 @@ jobs:
TEST_SHOPIFY_SHOP_URL: ${{ secrets.TEST_SHOPIFY_SHOP_URL }}
TEST_APPLE_LOGIN_TOKEN: ${{ secrets.TEST_APPLE_LOGIN_TOKEN }}
TEST_APOLLO_KEY: ${{ secrets.TEST_APOLLO_KEY }}
TEST_STRIPE_SECRET_KEY: ${{ secrets.TEST_STRIPE_SECRET_KEY }}
strategy:
fail-fast: false
matrix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ShopifyInventoryDownloadCommand extends Command
*
* @var string
*/
protected $signature = '343 {app_id} {branch_id} {warehouse_id}';
protected $signature = 'kanvas:inventory-shopify-sync {app_id} {branch_id} {warehouse_id}';

/**
* The console command description.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Console\Commands;
namespace App\Console\Commands\Workflows;

use Illuminate\Console\Command;
use Kanvas\Apps\Models\Apps;
Expand Down
62 changes: 62 additions & 0 deletions app/Console/Commands/Workflows/KanvasCreateReceiverCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands\Workflows;

use Illuminate\Console\Command;
use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Models\Companies;
use Kanvas\Users\Repositories\UsersRepository;
use Kanvas\Workflow\Models\ReceiverWebhook;
use Kanvas\Workflow\Models\WorkflowAction;

use function Laravel\Prompts\select;

class KanvasCreateReceiverCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'kanvas:create-receiver-workflow';

public function handle(): void
{
$this->info('Creating Receiver...');
$app = select(
label: 'Select the app for the receiver: ',
options: Apps::pluck('name', 'id'),
);

$action = select(
label: 'Select the action for the receiver: ',
options: WorkflowAction::pluck('name', 'id'),
);

$userId = $this->ask('Enter the user ID for the receiver: ');
$companyId = $this->ask('Enter the company ID for the receiver: ');
$name = $this->ask('Enter the name for the receiver: ');
$description = $this->ask('Enter the description for the receiver: ');

$company = Companies::getById($companyId);

$user = UsersRepository::getUserOfCompanyById($company, (int)$userId);

$receiver = ReceiverWebhook::create([
'apps_id' => $app,
'action_id' => $action,
'companies_id' => $company->getId(),
'users_id' => $user->getId(),
'name' => $name,
'description' => $description,
'is_active' => true,
'is_deleted' => false,
]);

$this->info('Receiver created successfully!');
$url = config('app.url') . '/receiver/' . $receiver->uuid;
$this->info('Webhook URL: ' . $url);
}
}
42 changes: 42 additions & 0 deletions app/GraphQL/Guild/Queries/PeopleManagementQueries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Guild\Queries;

use Baka\Traits\KanvasScopesTrait;
use Kanvas\Enums\StateEnums;
use Kanvas\Guild\Customers\Models\People;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;

class PeopleManagementQueries
{
use KanvasScopesTrait;
protected string $table = 'peoples';

public function countByTag(mixed $root, array $request, GraphQLContext $context): int
{
$builder = People::whereHas('tags', function ($query) use ($request) {
$query->where('tags.name', $request['tag']);
});

$builder->where('is_deleted', StateEnums::NO->getValue());
$builder = $this->scopeFromCompany($builder);
$builder = $this->scopeFromApp($builder);

return $builder->count();
}

public function getBySubscriptionType(mixed $root, array $request, GraphQLContext $context): int
{
$builder = People::whereHas('subscriptions', function ($query) use ($request) {
$query->where('peoples_subscriptions.subscription_type', $request['type']);
});

$builder->where('is_deleted', StateEnums::NO->getValue());
$builder = $this->scopeFromCompany($builder);
$builder = $this->scopeFromApp($builder);

return $builder->count();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Social\Builders\Interactions;

use Baka\Enums\StateEnums;
use GraphQL\Type\Definition\ResolveInfo;
use Illuminate\Database\Eloquent\Builder;
use Kanvas\Social\Interactions\Models\EntityInteractions;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;

class EntityInteractionsBuilder
{
public function getAll(
mixed $root,
array $args,
GraphQLContext $context,
ResolveInfo $resolveInfo
): Builder {
return EntityInteractions::where('entity_id', '=', $root->uuid)
->where('entity_namespace', '=', $root::class)
->where('is_deleted', '=', StateEnums::NO->getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace App\GraphQL\Social\Mutations\Channels;

use Baka\Support\Str;
use Exception;
use Kanvas\AccessControlList\Enums\RolesEnums;
use Kanvas\AccessControlList\Repositories\RolesRepository;
use Kanvas\Apps\Models\Apps;
use Kanvas\Social\Channels\Actions\CreateChannelAction;
Expand All @@ -12,7 +15,6 @@
use Kanvas\Social\Channels\Repositories\ChannelRepository;
use Kanvas\SystemModules\Repositories\SystemModulesRepository;
use Kanvas\Users\Models\Users;
use Baka\Support\Str;

class ChannelsManagementMutation
{
Expand All @@ -26,7 +28,7 @@ public function createChannel(mixed $rootValue, array $request): Channel
name: $request['input']['name'],
description: $request['input']['description'],
entity_id: $request['input']['entity_id'],
entity_namespace: $systemModule->uuid,
entity_namespace: $systemModule->model_name,
slug: $request['input']['slug'] ?? Str::slug($request['input']['name'])
);

Expand Down Expand Up @@ -65,7 +67,12 @@ public function attachUserToChannel(mixed $rootValue, array $request): Channel
{
$channel = ChannelRepository::getById((int)$request['input']['channel_id'], auth()->user());
$user = Users::getByIdFromCompany($request['input']['user_id'], auth()->user()->getCurrentCompany());
$roles = RolesRepository::getByIdFromCompany($request['input']['roles_id'], auth()->user()->getCurrentCompany());

try {
$roles = RolesRepository::getByMixedParamFromCompany($request['input']['roles_id'], auth()->user()->getCurrentCompany());
} catch (Exception $e) {
$roles = RolesRepository::getByMixedParamFromCompany(RolesEnums::USER->value, auth()->user()->getCurrentCompany());
}
$channel->users()->attach($user->id, ['roles_id' => $roles->id]);

return $channel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@
use Kanvas\Apps\Models\Apps;
use Kanvas\Auth\Exceptions\AuthenticationException;
use Kanvas\Exceptions\ValidationException;
use Kanvas\Social\Enums\InteractionEnum;
use Kanvas\Social\Interactions\Actions\CreateInteraction;
use Kanvas\Social\Interactions\DataTransferObject\Interaction;
use Kanvas\Social\Messages\Actions\CreateMessageAction;
use Kanvas\Social\Messages\Actions\DistributeChannelAction;
use Kanvas\Social\Messages\Actions\DistributeToUsers;
use Kanvas\Social\Messages\DataTransferObject\MessageInput;
use Kanvas\Social\Messages\Enums\ActivityTypeEnum;
use Kanvas\Social\Messages\Enums\DistributionTypeEnum;
use Kanvas\Social\Messages\Models\Message;
use Kanvas\Social\Messages\Services\MessageInteractionService;
use Kanvas\Social\Messages\Validations\ValidParentMessage;
use Kanvas\Social\MessagesTypes\Actions\CreateMessageTypeAction;
use Kanvas\Social\MessagesTypes\DataTransferObject\MessageTypeInput;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ReceiverController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Kanvas\Apps\Models\Apps;
use Kanvas\Connectors\Zoho\Actions\SyncZohoAgentAction;
use Kanvas\Connectors\Zoho\Actions\SyncZohoLeadAction;
Expand All @@ -30,7 +31,6 @@ public function store(string $uuid, Request $request): JsonResponse
{
$app = app(Apps::class);
$receiver = ReceiverWebhook::where('uuid', $uuid)->notDeleted()->first();

if ($receiver) {
// return response()->json(['message' => 'Receiver not found'], 404);
if ($app->getId() != $receiver->apps_id) {
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"spatie/laravel-health": "^1.27",
"spatie/laravel-queueable-action": "^2.15",
"spatie/laravel-webhook-server": "^3.8",
"stripe/stripe-php": "^15.0",
"symfony/expression-language": "^7.0",
"symfony/http-client": "^7.0",
"symfony/mailgun-mailer": "^7.0",
Expand Down
Loading

0 comments on commit 1b8c8e2

Please sign in to comment.