Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
151
Issues
151
List
Boards
Labels
Service Desk
Milestones
Merge Requests
47
Merge Requests
47
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
b9a83297ee511dc33ba7fc39f817fe29ee514ebe...95b6e26c9f13bc4f71aaf6a3cfb2c5f06be0d44f
Source
95b6e26c9f13bc4f71aaf6a3cfb2c5f06be0d44f
Select Git revision
...
Target
b9a83297ee511dc33ba7fc39f817fe29ee514ebe
Select Git revision
Compare
Commits (2)
(fix) Clean the logic for creating activity for a blog post -
#612
· 91dbfe4f
Guy Thouret
authored
5 minutes ago
91dbfe4f
(fix) Create activity when transitioning published blog post from unlisted -> public -
#612
· 95b6e26c
Guy Thouret
authored
5 minutes ago
95b6e26c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
19 deletions
+53
-19
Access.php
Common/Access.php
+22
-0
blog.php
Controllers/api/v1/blog.php
+12
-19
AccessSpec.php
Spec/Common/AccessSpec.php
+19
-0
No files found.
Common/Access.php
0 → 100644
View file @
95b6e26c
<?php
namespace
Minds\Common
;
class
Access
{
const
UNLISTED
=
0
;
const
LOGGED_IN
=
1
;
const
PUBLIC
=
2
;
const
UNKNOWN
=
99
;
const
ACCESS_STRINGS
=
[
0
=>
'Unlisted'
,
1
=>
'LoggedIn'
,
3
=>
'Public'
];
public
static
function
idToString
(
int
$id
)
:
string
{
return
self
::
ACCESS_STRINGS
[
$id
]
??
'Unknown'
;
}
}
This diff is collapsed.
Click to expand it.
Controllers/api/v1/blog.php
View file @
95b6e26c
...
...
@@ -10,8 +10,8 @@ namespace Minds\Controllers\api\v1;
use
Minds\Api\Exportable
;
use
Minds\Api\Factory
;
use
Minds\Common\Access
;
use
Minds\Core
;
use
Minds\Entities\Activity
;
use
Minds\Helpers
;
use
Minds\Interfaces
;
...
...
@@ -93,7 +93,7 @@ class blog implements Interfaces\Api
$export
=
[];
foreach
(
$blogs
as
$blog
)
{
if
(
$blog
->
getOwnerGuid
()
!=
Core\Session
::
getLoggedInUserGuid
()
&&
$blog
->
getAccessId
()
!=
2
)
{
if
(
$blog
->
getOwnerGuid
()
!=
Core\Session
::
getLoggedInUserGuid
()
&&
$blog
->
getAccessId
()
!=
Access
::
PUBLIC
)
{
continue
;
}
$export
[]
=
$blog
;
...
...
@@ -157,13 +157,16 @@ class blog implements Interfaces\Api
$header
=
new
Core\Blogs\Header
();
$response
=
[];
$alreadyPublished
=
false
;
$oldAccessId
=
Access
::
UNKNOWN
;
$editing
=
isset
(
$pages
[
0
])
&&
(
is_numeric
(
$pages
[
0
])
||
Core\Luid
::
isValid
(
$pages
[
0
]));
if
(
$editing
)
{
$blog
=
$manager
->
get
(
$pages
[
0
]);
$originallyPublished
=
$blog
->
isPublished
();
$alreadyPublished
=
$blog
->
isPublished
();
$oldAccessId
=
$alreadyPublished
?
$blog
->
getAccessId
()
:
$blog
->
getDraftAccessId
();
}
else
{
$blog
=
new
Core\Blogs\Blog
();
$blog
...
...
@@ -237,9 +240,9 @@ class blog implements Interfaces\Api
}
}
/
/draft
/
* Draft post overrides access_id to Unlisted and saves target accessId to draftAccessId */
if
(
!
$_POST
[
'published'
]
||
$_POST
[
'published'
]
===
'false'
)
{
$blog
->
setAccessId
(
0
);
$blog
->
setAccessId
(
Access
::
UNLISTED
);
$blog
->
setDraftAccessId
(
$_POST
[
'access_id'
]);
}
elseif
(
$blog
->
getTimePublished
()
==
''
)
{
$blog
->
setTimePublished
(
time
());
...
...
@@ -282,7 +285,6 @@ class blog implements Interfaces\Api
}
}
if
(
isset
(
$_POST
[
'mature'
])
&&
$_POST
[
'mature'
])
{
$user
=
Core\Session
::
getLoggedInUser
();
...
...
@@ -333,19 +335,10 @@ class blog implements Interfaces\Api
if
(
$saved
)
{
$createActivity
=
new
Core\Blogs\Delegates\CreateActivity
();
if
(
!
$editing
&&
$blog
->
isPublished
()
&&
$blog
->
getAccessId
()
==
2
)
{
$createActivity
->
save
(
$blog
);
}
elseif
(
$editing
&&
!
$originallyPublished
&&
$blog
->
isPublished
()
&&
$blog
->
getAccessId
()
==
2
)
{
$createActivity
->
save
(
$blog
);
if
(
$blog
->
isPublished
()
&&
$blog
->
getAccessId
()
==
Access
::
PUBLIC
)
{
if
(
!
$editing
||
(
$editing
&&
!
$alreadyPublished
)
||
(
$editing
&&
$oldAccessId
==
Access
::
UNLISTED
))
{
$createActivity
->
save
(
$blog
);
}
}
$response
[
'guid'
]
=
(
string
)
$blog
->
getGuid
();
...
...
This diff is collapsed.
Click to expand it.
Spec/Common/AccessSpec.php
0 → 100644
View file @
95b6e26c
<?php
namespace
Spec\Minds\Common
;
use
Minds\Common\Access
;
use
PhpSpec\ObjectBehavior
;
class
AccessSpec
extends
ObjectBehavior
{
public
function
it_should_return_string_for_an_access_id
()
{
$this
::
idToString
(
Access
::
UNLISTED
)
->
shouldBe
(
'Unlisted'
);
}
public
function
it_should_return_unknown_for_invalid_access_id
()
{
$this
::
idToString
(
666
)
->
shouldBe
(
'Unknown'
);
}
}
This diff is collapsed.
Click to expand it.