Skip to content

Commit

Permalink
Enh #188: Add "Like" to message entries
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-farre committed May 13, 2024
1 parent 8aaf14b commit bd63705
Show file tree
Hide file tree
Showing 9 changed files with 415 additions and 342 deletions.
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Changelog
=========

3.2.2 (Unreleased)
Unreleased
----------------------
- Enh #382: Implement provider for meta searching
- Fix #389: Fix notification about participant joining
- Enh #188: Add "Like" to message entries

3.2.1 (April 15, 2024)
----------------------
Expand Down
2 changes: 1 addition & 1 deletion models/AbstractMessageEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @property integer $id
* @property integer $message_id
* @property integer $user_id
* @property string $content
* @property string|null $content
* @property integer $type
* @property string $created_at
* @property integer $created_by
Expand Down
31 changes: 30 additions & 1 deletion models/MessageEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
namespace humhub\modules\mail\models;

use DateTime;
use humhub\modules\content\widgets\richtext\AbstractRichText;
use humhub\modules\content\widgets\richtext\converter\RichTextToEmailHtmlConverter;
use humhub\modules\content\widgets\richtext\RichText;
use humhub\modules\like\interfaces\LikeNotificationInterface;
use humhub\modules\mail\helpers\Url;
use humhub\modules\user\models\User;
use Yii;
use yii\base\InvalidConfigException;

/**
* This class represents a message text within a conversation.
*
* @package humhub.modules.mail.models
* @since 0.5
*/
class MessageEntry extends AbstractMessageEntry
class MessageEntry extends AbstractMessageEntry implements LikeNotificationInterface
{
/**
* @inheritdoc
Expand Down Expand Up @@ -61,4 +67,27 @@ public function isFirstToday(): bool
->andWhere(['>=', 'created_at', $today])
->exists();
}

/**
* @inerhitdoc
* @throws InvalidConfigException
*/
public function getLikeNotificationPlainTextPreview(): string
{
return Yii::t('MailModule.base', 'Message') . ' ' . RichText::convert($this->content, AbstractRichText::FORMAT_SHORTTEXT);
}

/**
* @inerhitdoc
* @throws InvalidConfigException
*/
public function getLikeNotificationHtmlPreview(): string
{
return RichTextToEmailHtmlConverter::process($this->content);
}

public function getLikeNotificationUrl(bool $scheme = false): string
{
return Url::toMessenger($this->message, $scheme);
}
}
58 changes: 29 additions & 29 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"id": "mail",
"name": "Messenger",
"description": "A private messaging system for direct communication.",
"keywords": [
"mail",
"messaging",
"messenger",
"communication"
],
"version": "3.2.2",
"humhub": {
"minVersion": "1.16"
},
"homepage": "https://github.com/humhub/mail",
"authors": [
{
"name": "Andreas Strobel"
"id": "mail",
"name": "Messenger",
"description": "A private messaging system for direct communication.",
"keywords": [
"mail",
"messaging",
"messenger",
"communication"
],
"version": "3.2.2",
"humhub": {
"minVersion": "1.16.0"
},
{
"name": "Lucas Bartholemy"
},
{
"name": "Julian Harrer"
}
],
"screenshots": [
"resources/screen1.PNG",
"resources/screen2.PNG",
"resources/screen3.PNG"
]
"homepage": "https://github.com/humhub/mail",
"authors": [
{
"name": "Andreas Strobel"
},
{
"name": "Lucas Bartholemy"
},
{
"name": "Julian Harrer"
}
],
"screenshots": [
"resources/screen1.PNG",
"resources/screen2.PNG",
"resources/screen3.PNG"
]
}
1 change: 1 addition & 0 deletions resources/css/humhub.mail.css
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
float: right;
font-size: 10px;
color: var(--text-color-main);
padding-top: 4px;
}
.mail-conversation-entry .conversation-entry-time > span {
font-style: italic;
Expand Down
Loading

0 comments on commit bd63705

Please sign in to comment.