Skip to content

Commit

Permalink
Added expandable quotes when publishing messages in Telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Jun 24, 2024
1 parent e373d8b commit bcea97d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 61 deletions.
15 changes: 6 additions & 9 deletions app/Data/Casts/ChangelogCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ class ChangelogCast implements Cast
'allow_unsafe_links' => false,
];

protected array $tagsFrom = ['h2', '<li>', '</li>'];
protected array $tagsFrom = ['h2', '<li>', '</li>', '<ul>', '</ul>'];

protected array $tagsTo = ['b', '- ', ''];
protected array $tagsTo = ['b', '- ', '', '<blockquote expandable>', '</blockquote>'];

protected array $allowedTags = ['h2', 'li', 'i', 'em'];
protected array $allowedTags = ['h2', 'li', 'i', 'em', 'ul'];

protected string $resolveSpaces = '/<li>\n?\s*(.+)\n?\s*<\/li>/';

public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): string
{
return Str::of($this->removeEmojis($value))
->replaceMatches([$this->from, $this->fullLink], '')
->replaceMatches($this->contributors, $this->contributor)
->trim()
->limitRows($this->limit())
->markdown($this->options)
->replaceMatches($this->resolveSpaces, '<li>$1</li>')
->stripTags($this->allowedTags)
->replace($this->tagsFrom, $this->tagsTo)
->replaceMatches('/-\s+\[(.+)]/', $this->listItem)
Expand Down Expand Up @@ -67,9 +69,4 @@ protected function emoji(): EmojiDetector
{
return new EmojiDetector();
}

protected function limit(): int
{
return config('services.telegram.changelog.limit');
}
}
Empty file removed app/Providers/.gitkeep
Empty file.
46 changes: 0 additions & 46 deletions app/Providers/StringServiceProvider.php

This file was deleted.

2 changes: 0 additions & 2 deletions bootstrap/providers.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

use App\Providers\IntegrationServiceProvider;
use App\Providers\StringServiceProvider;

return [
StringServiceProvider::class,
IntegrationServiceProvider::class,
];
4 changes: 0 additions & 4 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
'webhooks-service',
],

'changelog' => [
'limit' => 20,
],

'max_errors' => 10,
],

Expand Down

0 comments on commit bcea97d

Please sign in to comment.