1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Message\Lib; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
9
|
|
|
use Stu\Orm\Entity\ContactInterface; |
10
|
|
|
use Stu\Orm\Entity\PrivateMessageInterface; |
11
|
|
|
use Stu\Orm\Entity\UserInterface; |
12
|
|
|
use Stu\Orm\Repository\ContactRepositoryInterface; |
13
|
|
|
use Stu\Orm\Repository\PrivateMessageRepositoryInterface; |
14
|
|
|
|
15
|
|
|
class PrivateMessageListItem implements PrivateMessageListItemInterface |
16
|
|
|
{ |
17
|
|
|
private ?UserInterface $sender = null; |
18
|
|
|
|
19
|
|
|
private ?ContactInterface $sendercontact = null; |
20
|
|
|
|
21
|
|
|
public function __construct( |
22
|
|
|
private PrivateMessageRepositoryInterface $privateMessageRepository, |
23
|
|
|
private ContactRepositoryInterface $contactRepository, |
24
|
|
|
private PrivateMessageInterface $message, |
25
|
|
|
private int $currentUserId |
26
|
|
|
) {} |
27
|
|
|
|
28
|
|
|
#[Override] |
29
|
|
|
public function getSender(): UserInterface |
30
|
|
|
{ |
31
|
|
|
if ($this->sender === null) { |
32
|
|
|
$this->sender = $this->message->getSender(); |
33
|
|
|
} |
34
|
|
|
return $this->sender; |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
#[Override] |
38
|
|
|
public function getDate(): int |
39
|
|
|
{ |
40
|
|
|
return $this->message->getDate(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
#[Override] |
44
|
|
|
public function isMarkableAsNew(): bool |
45
|
|
|
{ |
46
|
|
|
if ($this->message->getNew() === false) { |
47
|
|
|
return false; |
48
|
|
|
} |
49
|
|
|
$this->message->setNew(false); |
50
|
|
|
$this->privateMessageRepository->save($this->message, true); |
51
|
|
|
|
52
|
|
|
return true; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
#[Override] |
56
|
|
|
public function isMarkableAsReceipt(): bool |
57
|
|
|
{ |
58
|
|
|
$inboxPm = $this->message->getInboxPm(); |
59
|
|
|
if ($inboxPm === null) { |
60
|
|
|
return false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if ( |
64
|
|
|
!$this->message->getSender()->isShowPmReadReceipt() |
65
|
|
|
|| !$this->message->getRecipient()->isShowPmReadReceipt() |
66
|
|
|
) { |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if ($inboxPm->isDeleted()) { |
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return !$inboxPm->getNew(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
#[Override] |
78
|
|
|
public function getText(): string |
79
|
|
|
{ |
80
|
|
|
return $this->message->getText(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
#[Override] |
84
|
|
|
public function getHref(): ?string |
85
|
|
|
{ |
86
|
|
|
return $this->message->getHref(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
#[Override] |
90
|
|
|
public function getNew(): bool |
91
|
|
|
{ |
92
|
|
|
return $this->message->getNew(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
#[Override] |
96
|
|
|
public function getId(): int |
97
|
|
|
{ |
98
|
|
|
return $this->message->getId(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
#[Override] |
102
|
|
|
public function displayUserLinks(): bool |
103
|
|
|
{ |
104
|
|
|
return $this->getSender() && $this->getSender()->getId() !== UserEnum::USER_NOONE; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
#[Override] |
108
|
|
|
public function getReplied(): bool |
109
|
|
|
{ |
110
|
|
|
return $this->message->getReplied(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
#[Override] |
114
|
|
|
public function senderIsContact(): ?ContactInterface |
115
|
|
|
{ |
116
|
|
|
if ($this->sendercontact === null) { |
117
|
|
|
$this->sendercontact = $this->contactRepository->getByUserAndOpponent( |
118
|
|
|
$this->currentUserId, |
119
|
|
|
$this->message->getSenderId() |
120
|
|
|
); |
121
|
|
|
} |
122
|
|
|
return $this->sendercontact; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
#[Override] |
126
|
|
|
public function hasTranslation(): bool |
127
|
|
|
{ |
128
|
|
|
$text = $this->getText(); |
129
|
|
|
return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false; |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths