File tree Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Original file line number Diff line number Diff line change 8
8
use Minds \Entities \RepositoryEntity ;
9
9
use Minds \Entities \User ;
10
10
use Minds \Helpers \Flags ;
11
+ use Minds \Helpers \Unknown ;
11
12
12
13
/**
13
14
* Comment Entity
@@ -271,6 +272,13 @@ protected function _extendExport(array $export)
271
272
$ output ['ownerObj ' ] = $ this ->getOwnerObj ();
272
273
$ output ['description ' ] = $ this ->getBody ();
273
274
275
+ if (!$ output ['ownerObj ' ] && !$ this ->getOwnerGuid ()) {
276
+ $ unknown = Unknown::user ();
277
+
278
+ $ output ['ownerObj ' ] = $ unknown ->export ();
279
+ $ output ['owner_guid ' ] = $ unknown ->guid ;
280
+ }
281
+
274
282
if ($ export ['attachments ' ]) {
275
283
foreach ($ export ['attachments ' ] as $ key => $ value ) {
276
284
$ output ['attachments ' ][$ key ] = $ this ->getAttachment ($ key );
Original file line number Diff line number Diff line change @@ -77,7 +77,10 @@ public function add(Comment $comment)
77
77
{
78
78
$ entity = $ this ->entitiesBuilder ->single ($ comment ->getEntityGuid ());
79
79
80
- if (!$ this ->acl ->interact ($ entity )) {
80
+ if (
81
+ !$ comment ->getOwnerGuid () ||
82
+ !$ this ->acl ->interact ($ entity , $ comment ->getOwnerEntity (true ))
83
+ ) {
81
84
throw new BlockedUserException ();
82
85
}
83
86
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Description
5
+ *
6
+ * @author emi
7
+ */
8
+
9
+ namespace Minds \Helpers ;
10
+
11
+ use Minds \Entities \User ;
12
+
13
+ class Unknown
14
+ {
15
+ /**
16
+ * @return User
17
+ * @throws \Exception
18
+ */
19
+ public static function user ()
20
+ {
21
+ $ user = new User ();
22
+
23
+ $ user ->guid = 0 ;
24
+ $ user ->username = '' ;
25
+ $ user ->name = 'Unknown User ' ;
26
+
27
+ return $ user ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change 13
13
use Minds \Core \Luid ;
14
14
use Minds \Core \Security \ACL ;
15
15
use Minds \Entities \Entity ;
16
+ use Minds \Entities \User ;
16
17
use Minds \Exceptions \BlockedUserException ;
17
18
use PhpSpec \ObjectBehavior ;
18
19
use Prophecy \Argument ;
@@ -81,9 +82,18 @@ function it_is_initializable()
81
82
82
83
function it_should_add (
83
84
Comment $ comment ,
84
- Entity $ entity
85
+ Entity $ entity ,
86
+ User $ owner
85
87
)
86
88
{
89
+ $ comment ->getOwnerEntity (true )
90
+ ->shouldBeCalled ()
91
+ ->willReturn ($ owner );
92
+
93
+ $ comment ->getOwnerGuid ()
94
+ ->shouldBeCalled ()
95
+ ->willReturn (1000 );
96
+
87
97
$ comment ->getEntityGuid ()
88
98
->shouldBeCalled ()
89
99
->willReturn (5000 );
@@ -92,7 +102,7 @@ function it_should_add(
92
102
->shouldBeCalled ()
93
103
->willReturn ($ entity );
94
104
95
- $ this ->acl ->interact ($ entity )
105
+ $ this ->acl ->interact ($ entity, $ owner )
96
106
->shouldBeCalled ()
97
107
->willReturn (true );
98
108
@@ -127,9 +137,18 @@ function it_should_add(
127
137
128
138
function it_should_throw_if_blocked_user_during_add (
129
139
Comment $ comment ,
130
- Entity $ entity
140
+ Entity $ entity ,
141
+ User $ owner
131
142
)
132
143
{
144
+ $ comment ->getOwnerEntity (true )
145
+ ->shouldBeCalled ()
146
+ ->willReturn ($ owner );
147
+
148
+ $ comment ->getOwnerGuid ()
149
+ ->shouldBeCalled ()
150
+ ->willReturn (1000 );
151
+
133
152
$ comment ->getEntityGuid ()
134
153
->shouldBeCalled ()
135
154
->willReturn (5000 );
@@ -138,7 +157,7 @@ function it_should_throw_if_blocked_user_during_add(
138
157
->shouldBeCalled ()
139
158
->willReturn ($ entity );
140
159
141
- $ this ->acl ->interact ($ entity )
160
+ $ this ->acl ->interact ($ entity, $ owner )
142
161
->shouldBeCalled ()
143
162
->willReturn (false );
144
163
You can’t perform that action at this time.
0 commit comments