Skip to content

Commit

Permalink
🧑‍💻 get likes_ and points_enabled via settings api (#2825)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Aug 7, 2024
1 parent 95dafe1 commit c31627d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Http/Resources/UserProfileSettingsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @OA\Property(property="mastodon", type="string", example="https://mastodon.social/@Gertrud123"),
* @OA\Property(property="mastodonVisibility", ref="#/components/schemas/MastodonVisibility"),
* @OA\Property(property="friendCheckin", ref="#/components/schemas/FriendCheckinSetting"),
* @OA\Property(property="likesEnabled", type="boolean", example=true),
* @OA\Property(property="pointsEnabled", type="boolean", example=true),
* )
*/
class UserProfileSettingsResource extends JsonResource
Expand All @@ -42,6 +44,8 @@ public function toArray($request): array {
'mastodon' => $this->mastodon_url,
'mastodonVisibility' => $this->socialProfile->mastodon_visibility->value,
'friendCheckin' => $this->friend_checkin?->value,
'likesEnabled' => (bool) $this->likes_enabled,
'pointsEnabled' => (bool) $this->points_enabled,
];
}
}
1 change: 1 addition & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function definition(): array {
'privacy_hide_days' => $this->faker->numberBetween(7, 365),
'language' => null,
'likes_enabled' => true,
'points_enabled' => true,
'friend_checkin' => FriendCheckinSetting::FORBIDDEN,
];
}
Expand Down
8 changes: 8 additions & 0 deletions storage/api-docs/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5415,6 +5415,14 @@
},
"friendCheckin": {
"$ref": "#/components/schemas/FriendCheckinSetting"
},
"likesEnabled": {
"type": "boolean",
"example": true
},
"pointsEnabled": {
"type": "boolean",
"example": true
}
},
"type": "object"
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/APIv1/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function testGetProfileSettings(): void {
]);

$this->assertEquals(FriendCheckinSetting::FORBIDDEN->value, $response->json('data.friendCheckin'));
$this->assertTrue($response->json('data.likesEnabled'));
$this->assertTrue($response->json('data.pointsEnabled'));
}

public function testUpdateProfileSettings(): void {
Expand Down

0 comments on commit c31627d

Please sign in to comment.