Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
Nextcloud Notifier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
Nextcloud Notifier
Commits
eaac5da4
Commit
eaac5da4
authored
4 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Actual implementation.
Remove runamel.yaml, json output is available and better.
parent
4b7ba4a5
No related branches found
No related tags found
No related merge requests found
Pipeline
#1170
passed
4 years ago
Stage: test
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+30
-6
30 additions, 6 deletions
app.py
requirements.txt
+0
-1
0 additions, 1 deletion
requirements.txt
with
30 additions
and
7 deletions
app.py
+
30
−
6
View file @
eaac5da4
"""
Anonymous push notification service for Nextcloud.
"""
"""
Anonymous push notification service for Nextcloud.
"""
# pylint: disable=import-error
# pylint: disable=import-error
import
json
import
os
import
os
import
docker
import
docker
from
flask
import
Flask
,
request
from
flask
import
Flask
,
request
from
ruamel.yaml
import
YAML
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
client
=
docker
.
from_env
()
client
=
docker
.
from_env
()
yaml
=
YAML
(
typ
=
"
safe
"
)
USER
NAME
=
os
.
getenv
(
"
NC_
USER
NAME
"
,
"
n
imrod
"
)
NAME
=
os
.
getenv
(
"
NC_NAME
"
,
"
N
imrod
Adar
"
)
CONTAINER_NAME
=
os
.
getenv
(
"
NC_CONTAINER
"
,
"
nextcloud_nextcloud_1
"
)
CONTAINER_NAME
=
os
.
getenv
(
"
NC_CONTAINER
"
,
"
nextcloud_nextcloud_1
"
)
...
@@ -35,7 +34,32 @@ def send_message():
...
@@ -35,7 +34,32 @@ def send_message():
message
=
data
message
=
data
else
:
else
:
message
=
request
.
args
[
"
message
"
]
message
=
request
.
args
[
"
message
"
]
return
message
# result = container.exec_run(
for
c
in
client
.
containers
.
list
():
# pylint: disable=invalid-name
# f"""./occ notification:generate -- {user_id} "{message}"""")
if
c
.
name
==
CONTAINER_NAME
:
container
=
c
break
else
:
raise
RuntimeError
(
f
"
Failed to find container
{
CONTAINER_NAME
}
.
"
)
users
=
json
.
loads
(
container
.
exec_run
(
"
./occ user:list --output json --info
"
,
user
=
"
www-data
"
).
output
)
for
(
k
,
v
)
in
users
.
items
():
# pylint: disable=invalid-name
if
v
[
"
display_name
"
]
==
NAME
:
uid
=
k
break
else
:
raise
RuntimeError
(
f
"
Failed to find user
{
NAME
}
.
"
)
result
=
container
.
exec_run
(
f
"""
./occ notification:generate --
{
uid
}
'
{
message
}
'"""
,
user
=
"
www-data
"
,
)
if
result
.
exit_code
!=
0
:
raise
RuntimeError
(
result
.
output
.
decode
())
return
message
This diff is collapsed.
Click to expand it.
requirements.txt
+
0
−
1
View file @
eaac5da4
docker
docker
flask
flask
gunicorn
gunicorn
ruamel.yaml
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment