Skip to content

Commit bd63705

Browse files
committed
Enh #188: Add "Like" to message entries
1 parent 8aaf14b commit bd63705

9 files changed

+415
-342
lines changed

docs/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Changelog
22
=========
33

4-
3.2.2 (Unreleased)
4+
Unreleased
55
----------------------
66
- Enh #382: Implement provider for meta searching
77
- Fix #389: Fix notification about participant joining
8+
- Enh #188: Add "Like" to message entries
89

910
3.2.1 (April 15, 2024)
1011
----------------------

models/AbstractMessageEntry.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @property integer $id
2222
* @property integer $message_id
2323
* @property integer $user_id
24-
* @property string $content
24+
* @property string|null $content
2525
* @property integer $type
2626
* @property string $created_at
2727
* @property integer $created_by

models/MessageEntry.php

+30-1
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
namespace humhub\modules\mail\models;
44

55
use DateTime;
6+
use humhub\modules\content\widgets\richtext\AbstractRichText;
7+
use humhub\modules\content\widgets\richtext\converter\RichTextToEmailHtmlConverter;
8+
use humhub\modules\content\widgets\richtext\RichText;
9+
use humhub\modules\like\interfaces\LikeNotificationInterface;
10+
use humhub\modules\mail\helpers\Url;
611
use humhub\modules\user\models\User;
712
use Yii;
13+
use yii\base\InvalidConfigException;
814

915
/**
1016
* This class represents a message text within a conversation.
1117
*
1218
* @package humhub.modules.mail.models
1319
* @since 0.5
1420
*/
15-
class MessageEntry extends AbstractMessageEntry
21+
class MessageEntry extends AbstractMessageEntry implements LikeNotificationInterface
1622
{
1723
/**
1824
* @inheritdoc
@@ -61,4 +67,27 @@ public function isFirstToday(): bool
6167
->andWhere(['>=', 'created_at', $today])
6268
->exists();
6369
}
70+
71+
/**
72+
* @inerhitdoc
73+
* @throws InvalidConfigException
74+
*/
75+
public function getLikeNotificationPlainTextPreview(): string
76+
{
77+
return Yii::t('MailModule.base', 'Message') . ' ' . RichText::convert($this->content, AbstractRichText::FORMAT_SHORTTEXT);
78+
}
79+
80+
/**
81+
* @inerhitdoc
82+
* @throws InvalidConfigException
83+
*/
84+
public function getLikeNotificationHtmlPreview(): string
85+
{
86+
return RichTextToEmailHtmlConverter::process($this->content);
87+
}
88+
89+
public function getLikeNotificationUrl(bool $scheme = false): string
90+
{
91+
return Url::toMessenger($this->message, $scheme);
92+
}
6493
}

module.json

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"id": "mail",
3-
"name": "Messenger",
4-
"description": "A private messaging system for direct communication.",
5-
"keywords": [
6-
"mail",
7-
"messaging",
8-
"messenger",
9-
"communication"
10-
],
11-
"version": "3.2.2",
12-
"humhub": {
13-
"minVersion": "1.16"
14-
},
15-
"homepage": "https://github.com/humhub/mail",
16-
"authors": [
17-
{
18-
"name": "Andreas Strobel"
2+
"id": "mail",
3+
"name": "Messenger",
4+
"description": "A private messaging system for direct communication.",
5+
"keywords": [
6+
"mail",
7+
"messaging",
8+
"messenger",
9+
"communication"
10+
],
11+
"version": "3.2.2",
12+
"humhub": {
13+
"minVersion": "1.16.0"
1914
},
20-
{
21-
"name": "Lucas Bartholemy"
22-
},
23-
{
24-
"name": "Julian Harrer"
25-
}
26-
],
27-
"screenshots": [
28-
"resources/screen1.PNG",
29-
"resources/screen2.PNG",
30-
"resources/screen3.PNG"
31-
]
15+
"homepage": "https://github.com/humhub/mail",
16+
"authors": [
17+
{
18+
"name": "Andreas Strobel"
19+
},
20+
{
21+
"name": "Lucas Bartholemy"
22+
},
23+
{
24+
"name": "Julian Harrer"
25+
}
26+
],
27+
"screenshots": [
28+
"resources/screen1.PNG",
29+
"resources/screen2.PNG",
30+
"resources/screen3.PNG"
31+
]
3232
}

resources/css/humhub.mail.css

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
float: right;
242242
font-size: 10px;
243243
color: var(--text-color-main);
244+
padding-top: 4px;
244245
}
245246
.mail-conversation-entry .conversation-entry-time > span {
246247
font-style: italic;

0 commit comments

Comments
 (0)