Skip to content

Commit b5f2e59

Browse files
committed
(feat): Search graphql support minds#4127
1 parent 731d669 commit b5f2e59

File tree

44 files changed

+1653
-959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1653
-959
lines changed

Controllers/Cli/PartnerEarnings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public function resetRpm()
7979
var_dump($user->getPartnerRpm());
8080

8181
$manager = new Manager();
82-
// $manager->resetRpm($user, $this->getOpt('rpm') ?: 1);
82+
// $manager->resetRpm($user, $this->getOpt('rpm') ?: 1);
8383

8484
$daysAgo = 180;
85-
// var_dump($user->getPartnerRpm());
85+
// var_dump($user->getPartnerRpm());
8686

8787
while (--$daysAgo >= 0) {
8888
$this->out($daysAgo);

Controllers/Cli/User.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Minds\Exceptions;
99
use Minds\Entities;
1010
use Minds\Core\Channels\Ban;
11+
use Minds\Core\Di\Di;
1112

1213
class User extends Cli\Controller implements Interfaces\CliControllerInterface
1314
{
@@ -83,6 +84,28 @@ public function password_reset()
8384
}
8485
}
8586

87+
public function change_email()
88+
{
89+
try {
90+
if (!$this->getOpt('username') || !$this->getOpt('email')) {
91+
throw new Exceptions\CliException('Missing username / email');
92+
}
93+
94+
$username = $this->getOpt('username');
95+
$email = $this->getOpt('email');
96+
97+
$user = new Entities\User($username);
98+
99+
$user->email = $email;
100+
$user->save();
101+
102+
$this->out("Email changed successfuly for user ".$username);
103+
} catch (\Exception $e) {
104+
$this->out("An error has occured");
105+
$this->out($e);
106+
}
107+
}
108+
86109
/**
87110
* Ban a user.
88111
* Requires username.
@@ -104,6 +127,30 @@ public function ban()
104127
$this->out("Success if there are no errors above. Banned ".$username.".");
105128
}
106129

130+
/**
131+
* `php cli.php User baneFromCsv --csv=bans.svc --reason=16`
132+
*/
133+
public function banFromCsv()
134+
{
135+
$filename = $this->getOpt('csv');
136+
$row = 1;
137+
if (($handle = fopen($filename, "r")) !== false) {
138+
while (($data = fgetcsv($handle, 1000, ",")) !== false) {
139+
$guid = $data[0];
140+
$user = Di::_()->get('EntitiesBuilder')->single($guid);
141+
if (!$user instanceof Entities\User) {
142+
continue;
143+
}
144+
145+
$ban = new Ban();
146+
$ban->setUser($user);
147+
$this->out("Banning ".$user->getGuid()."...");
148+
$ban->ban($this->getOpt('reason') ?? 1);
149+
}
150+
fclose($handle);
151+
}
152+
}
153+
107154
/**
108155
* Unban a user.
109156
* Requires username.

Controllers/api/v2/blockchain/transactions.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -155,37 +155,37 @@ public function post($pages)
155155
}
156156
break;
157157
// case 'spend':
158-
// if (!$_POST['type']) {
159-
// return Factory::response([
160-
// 'status' => 'error',
161-
// 'message' => 'Type is required'
162-
// ]);
163-
// }
158+
// if (!$_POST['type']) {
159+
// return Factory::response([
160+
// 'status' => 'error',
161+
// 'message' => 'Type is required'
162+
// ]);
163+
// }
164164

165-
// $amount = BigNumber::_($_POST['amount']);
165+
// $amount = BigNumber::_($_POST['amount']);
166166

167-
// if ($amount->lte(0)) {
168-
// return Factory::response([
169-
// 'status' => 'error',
170-
// 'message' => 'Amount should be a positive number'
171-
// ]);
172-
// }
167+
// if ($amount->lte(0)) {
168+
// return Factory::response([
169+
// 'status' => 'error',
170+
// 'message' => 'Amount should be a positive number'
171+
// ]);
172+
// }
173173

174-
// /** @var Core\Blockchain\Wallets\OffChain\Transactions $transactions */
175-
// $transactions = Di::_()->get('Blockchain\Wallets\OffChain\Transactions');
174+
// /** @var Core\Blockchain\Wallets\OffChain\Transactions $transactions */
175+
// $transactions = Di::_()->get('Blockchain\Wallets\OffChain\Transactions');
176176

177-
// $transactions
178-
// ->setUser(Session::getLoggedinUser())
179-
// ->setType($_POST['type'])
180-
// ->setAmount((string) BigNumber::_($amount)->neg());
177+
// $transactions
178+
// ->setUser(Session::getLoggedinUser())
179+
// ->setType($_POST['type'])
180+
// ->setAmount((string) BigNumber::_($amount)->neg());
181181

182-
// $transaction = $transactions->create();
182+
// $transaction = $transactions->create();
183183

184-
// $response = [
185-
// 'txHash' => $transaction->getTx()
186-
// ];
184+
// $response = [
185+
// 'txHash' => $transaction->getTx()
186+
// ];
187187

188-
// break;
188+
// break;
189189
}
190190

191191
return Factory::response($response);

Controllers/fs/v1/avatars.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function get($pages)
3333
$type = $entity->type;
3434
}
3535

36-
if (method_exists($entity, 'getGuid')) {
36+
if ($entity && method_exists($entity, 'getGuid')) {
3737
$guid = $entity->getGuid();
38-
} elseif (property_exists($entity, 'guid')) {
38+
} elseif ($entity && property_exists($entity, 'guid')) {
3939
$guid = $entity->guid;
4040
}
4141

Controllers/fs/v1/banners.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function get($pages)
101101
}
102102
//$filepath = $f->getFilenameOnFilestore();
103103
//if (!file_exists($filepath)) {
104-
// $filepath = Core\Config::build()->dataroot . 'carousel/' . $entity->guid . $size;
104+
// $filepath = Core\Config::build()->dataroot . 'carousel/' . $entity->guid . $size;
105105
//}
106106
break;
107107
}

Core/Analytics/Graphs/Aggregates/Posts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function fetchAll($opts = [])
7171

7272
$result[$avgKey] = Manager::calculateAverages($result[$k]);
7373
}
74-
// var_dump(array_keys($result)); die();
74+
// var_dump(array_keys($result)); die();
7575
return $result;
7676
}
7777

Core/Authentication/Controller.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function __construct(
4040
* @throws UserNotSetupException
4141
* @throws RedisException
4242
*/
43-
// #[OA\Post(
44-
// path: '/api/v3/authenticate',
45-
// responses: [
46-
// new OA\Response(response: 200, description: "Ok"),
47-
// new OA\Response(response: 401, description: "Unauthorized"),
48-
// new OA\Response(response: 403, description: "Forbidden")
49-
// ]
50-
// )]
43+
// #[OA\Post(
44+
// path: '/api/v3/authenticate',
45+
// responses: [
46+
// new OA\Response(response: 200, description: "Ok"),
47+
// new OA\Response(response: 401, description: "Unauthorized"),
48+
// new OA\Response(response: 403, description: "Forbidden")
49+
// ]
50+
// )]
5151
public function authenticate(ServerRequest $request): JsonResponse
5252
{
5353
$requestValidator = new AuthenticationRequestValidator();
@@ -68,14 +68,14 @@ public function authenticate(ServerRequest $request): JsonResponse
6868
* @return JsonResponse
6969
* @throws Exception
7070
*/
71-
// #[OA\Delete(
72-
// path: '/api/v3/authenticate',
73-
// responses: [
74-
// new OA\Response(response: 200, description: "Ok"),
75-
// new OA\Response(response: 401, description: "Unauthorized"),
76-
// new OA\Response(response: 403, description: "Forbidden")
77-
// ]
78-
// )]
71+
// #[OA\Delete(
72+
// path: '/api/v3/authenticate',
73+
// responses: [
74+
// new OA\Response(response: 200, description: "Ok"),
75+
// new OA\Response(response: 401, description: "Unauthorized"),
76+
// new OA\Response(response: 403, description: "Forbidden")
77+
// ]
78+
// )]
7979
public function deleteSession(ServerRequestInterface $request): JsonResponse
8080
{
8181
$this->manager->deleteSession();
@@ -87,14 +87,14 @@ public function deleteSession(ServerRequestInterface $request): JsonResponse
8787
* @param ServerRequestInterface $request
8888
* @return JsonResponse
8989
*/
90-
// #[OA\Delete(
91-
// path: '/api/v3/authenticate/all',
92-
// responses: [
93-
// new OA\Response(response: 200, description: "Ok"),
94-
// new OA\Response(response: 401, description: "Unauthorized"),
95-
// new OA\Response(response: 403, description: "Forbidden")
96-
// ]
97-
// )]
90+
// #[OA\Delete(
91+
// path: '/api/v3/authenticate/all',
92+
// responses: [
93+
// new OA\Response(response: 200, description: "Ok"),
94+
// new OA\Response(response: 401, description: "Unauthorized"),
95+
// new OA\Response(response: 403, description: "Forbidden")
96+
// ]
97+
// )]
9898
public function deleteAllUserSessions(ServerRequestInterface $request): JsonResponse
9999
{
100100
$this->manager->deleteAllUserSessions();

Core/Blockchain/Wallets/OffChain/Sums.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public function getBalance()
5656
new Varint((int) $this->user->guid)
5757
]
5858
);
59-
// $query->setOpts([
59+
// $query->setOpts([
6060
// 'consistency' => \Cassandra::CONSISTENCY_ALL
61-
// ]);
61+
// ]);
6262
} else {
6363
//$query->query("SELECT SUM(amount) as balance from rewards");
6464
}
@@ -138,9 +138,9 @@ public function getCount(): int
138138
new Varint((int) $this->user->guid)
139139
]
140140
);
141-
// $query->setOpts([
141+
// $query->setOpts([
142142
// 'consistency' => \Cassandra::CONSISTENCY_ALL
143-
// ]);
143+
// ]);
144144
} else {
145145
return 0;
146146
}

Core/Entities/Controller.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ public function __construct(
2828
* @throws ForbiddenException
2929
* @throws NotFoundException
3030
*/
31-
// #[OA\Get(
32-
// path: '/api/v3/entities/:guid',
33-
// parameters: [
34-
// new OA\Parameter(
35-
// name: "guid",
36-
// in: "path",
37-
// required: true,
38-
// schema: new OA\Schema(type: 'string')
39-
// )
40-
// ],
41-
// responses: [
42-
// new OA\Response(response: 200, description: "Ok"),
43-
// new OA\Response(response: 400, description: "Bad Request"),
44-
// new OA\Response(response: 401, description: "Unauthorized"),
45-
// new OA\Response(response: 404, description: "Not found")
46-
// ]
47-
// )]
31+
// #[OA\Get(
32+
// path: '/api/v3/entities/:guid',
33+
// parameters: [
34+
// new OA\Parameter(
35+
// name: "guid",
36+
// in: "path",
37+
// required: true,
38+
// schema: new OA\Schema(type: 'string')
39+
// )
40+
// ],
41+
// responses: [
42+
// new OA\Response(response: 200, description: "Ok"),
43+
// new OA\Response(response: 400, description: "Bad Request"),
44+
// new OA\Response(response: 401, description: "Unauthorized"),
45+
// new OA\Response(response: 404, description: "Not found")
46+
// ]
47+
// )]
4848
public function getEntity(ServerRequestInterface $request): JsonResponse
4949
{
5050
$loggedInUser = $request->getAttribute("_user");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace Minds\Core\Feeds\Elastic\V2\Enums;
3+
4+
enum MediaTypeEnum
5+
{
6+
case ALL;
7+
case IMAGE;
8+
case VIDEO;
9+
case BLOG;
10+
}

Core/Feeds/Elastic/V2/Enums/SeenEntitiesFilterStrategyEnum.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22
namespace Minds\Core\Feeds\Elastic\V2\Enums;
33

4+
use TheCodingMachine\GraphQLite\Annotations\Input;
5+
6+
#[Input()]
47
enum SeenEntitiesFilterStrategyEnum
58
{
69
/**

0 commit comments

Comments
 (0)