Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
Backend Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SpinShare
Backend Server
Commits
dd1da501
Commit
dd1da501
authored
Feb 22, 2021
by
Laura Heimann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notification API call & documentation
parent
8f045a16
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
542 additions
and
0 deletions
+542
-0
public/assets/css/apidocs.css
public/assets/css/apidocs.css
+3
-0
public/assets/css/apidocs.less
public/assets/css/apidocs.less
+3
-0
src/Controller/API/APIDocsController.php
src/Controller/API/APIDocsController.php
+11
-0
src/Controller/API/Connect/APIConnectNotificationsController.php
...troller/API/Connect/APIConnectNotificationsController.php
+122
-0
templates/apidocs/base.html.twig
templates/apidocs/base.html.twig
+6
-0
templates/apidocs/connect/notifications.html.twig
templates/apidocs/connect/notifications.html.twig
+397
-0
No files found.
public/assets/css/apidocs.css
View file @
dd1da501
html
{
font-size
:
12px
!important
;
}
.sidebar
{
overflow-y
:
scroll
;
}
.sidebar-group
{
margin-top
:
25px
;
}
...
...
public/assets/css/apidocs.less
View file @
dd1da501
html {
font-size: 12px !important;
}
.sidebar {
overflow-y: scroll;
}
.sidebar-group {
margin-top: 25px;
}
...
...
src/Controller/API/APIDocsController.php
View file @
dd1da501
...
...
@@ -141,6 +141,17 @@ class APIDocsController extends AbstractController
return
$this
->
render
(
'apidocs/connect/profile.html.twig'
,
$data
);
}
/**
* @Route("/api/docs/connect/notifications", name="api.docs.connect.notifications")
*/
public
function
connectNotifications
(
Request
$request
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
return
$this
->
render
(
'apidocs/connect/notifications.html.twig'
,
$data
);
}
/**
* @Route("/api/docs/connect/reviews", name="api.docs.connect.reviews")
*/
...
...
src/Controller/API/Connect/APIConnectNotificationsController.php
0 → 100644
View file @
dd1da501
<?php
namespace
App\Controller\API\Connect
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\Routing\Generator\UrlGeneratorInterface
;
use
Symfony\Component\Routing\Annotation\Route
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpClient\HttpClient
;
use
App\Entity\User
;
use
App\Entity\Connection
;
use
App\Entity\ConnectApp
;
use
App\Entity\UserNotification
;
class
APIConnectNotificationsController
extends
AbstractController
{
/**
* @Route("/api/connect/notifications", name="api.connect.notifications")
* @Route("/api/connect/notifications/")
*/
public
function
getNotifications
(
Request
$request
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$connectToken
=
$request
->
query
->
get
(
'connectToken'
);
if
(
$connectToken
==
""
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
$connection
=
$em
->
getRepository
(
Connection
::
class
)
->
findOneBy
(
array
(
'connectToken'
=>
$connectToken
));
if
(
$connection
)
{
foreach
(
$connection
->
getUser
()
->
getUserNotifications
()
as
$notification
)
{
$data
[]
=
$notification
->
getJSON
();
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
return
$response
;
}
else
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
}
/**
* @Route("/api/connect/clearNotification", name="api.connect.clearNotification")
* @Route("/api/connect/clearNotification/")
*/
public
function
clearNotifications
(
Request
$request
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$connectToken
=
$request
->
query
->
get
(
'connectToken'
);
$notificationIDToClear
=
$request
->
query
->
get
(
'notificationID'
);
if
(
$connectToken
==
""
||
$notificationIDToClear
=
""
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
$connection
=
$em
->
getRepository
(
Connection
::
class
)
->
findOneBy
(
array
(
'connectToken'
=>
$connectToken
));
if
(
$connection
)
{
$notificationToClear
=
$em
->
getRepository
(
UserNotification
::
class
)
->
findOneBy
(
array
(
'id'
=>
$notificationIDToClear
,
'user'
=>
$connection
->
getUser
()));
if
(
$notificationToClear
)
{
$em
->
remove
(
$notificationToClear
);
$em
->
flush
();
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
[]]);
return
$response
;
}
else
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
404
,
'data'
=>
[]]);
return
$response
;
}
}
else
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
}
/**
* @Route("/api/connect/clearAllNotifications", name="api.connect.clearAllNotifications")
* @Route("/api/connect/clearAllNotifications/")
*/
public
function
clearAllNotifications
(
Request
$request
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$connectToken
=
$request
->
query
->
get
(
'connectToken'
);
if
(
$connectToken
==
""
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
$connection
=
$em
->
getRepository
(
Connection
::
class
)
->
findOneBy
(
array
(
'connectToken'
=>
$connectToken
));
if
(
$connection
)
{
$notificationsToClear
=
$em
->
getRepository
(
UserNotification
::
class
)
->
findBy
(
array
(
'user'
=>
$connection
->
getUser
()));
foreach
(
$notificationsToClear
as
$notificationToClear
)
{
$em
->
remove
(
$notificationToClear
);
$em
->
flush
();
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
[]]);
return
$response
;
}
else
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
}
}
templates/apidocs/base.html.twig
View file @
dd1da501
...
...
@@ -123,6 +123,12 @@
</span>
Profile
</a>
<a
href=
"
{{
path
(
'api.docs.connect.notifications'
)
}}
"
class=
"sidebar-link sidebar-link-with-icon
{%
if
app.request.attributes.get
(
'_route'
)
==
'api.docs.connect.notifications'
%}
active
{%
endif
%}
"
>
<span
class=
"sidebar-icon"
>
<i
class=
"mdi mdi-bell"
aria-hidden=
"true"
></i>
</span>
Notifications
</a>
<a
href=
"
{{
path
(
'api.docs.connect.reviews'
)
}}
"
class=
"sidebar-link sidebar-link-with-icon
{%
if
app.request.attributes.get
(
'_route'
)
==
'api.docs.connect.reviews'
%}
active
{%
endif
%}
"
>
<span
class=
"sidebar-icon"
>
<i
class=
"mdi mdi-thumbs-up-down"
aria-hidden=
"true"
></i>
...
...
templates/apidocs/connect/notifications.html.twig
0 → 100644
View file @
dd1da501
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment