selfprivacy-rest-api/selfprivacy_api/resources/services/pleroma.py

67 lines
1.5 KiB
Python
Raw Normal View History

2021-11-11 18:31:28 +00:00
#!/usr/bin/env python3
2021-11-16 16:14:01 +00:00
"""Pleroma management module"""
from flask_restful import Resource
2021-11-11 18:31:28 +00:00
from selfprivacy_api.resources.services import api
2021-11-22 16:50:50 +00:00
from selfprivacy_api.utils import WriteUserData
2021-11-11 18:31:28 +00:00
2021-11-16 16:14:01 +00:00
2021-11-11 18:31:28 +00:00
class EnablePleroma(Resource):
2021-11-16 16:14:01 +00:00
"""Enable Pleroma"""
2021-11-11 18:31:28 +00:00
def post(self):
2021-11-16 16:14:01 +00:00
"""
Enable Pleroma
---
tags:
- Pleroma
security:
- bearerAuth: []
responses:
200:
description: Pleroma enabled
401:
description: Unauthorized
"""
2021-11-22 16:50:50 +00:00
with WriteUserData() as data:
if "pleroma" not in data:
data["pleroma"] = {}
data["pleroma"]["enable"] = True
2021-11-11 18:31:28 +00:00
return {
"status": 0,
"message": "Pleroma enabled",
}
class DisablePleroma(Resource):
2021-11-16 16:14:01 +00:00
"""Disable Pleroma"""
2021-11-11 18:31:28 +00:00
def post(self):
2021-11-16 16:14:01 +00:00
"""
Disable Pleroma
---
tags:
- Pleroma
security:
- bearerAuth: []
responses:
200:
description: Pleroma disabled
401:
description: Unauthorized
"""
2021-11-22 16:50:50 +00:00
with WriteUserData() as data:
if "pleroma" not in data:
data["pleroma"] = {}
data["pleroma"]["enable"] = False
2021-11-11 18:31:28 +00:00
return {
"status": 0,
"message": "Pleroma disabled",
}
api.add_resource(EnablePleroma, "/pleroma/enable")
api.add_resource(DisablePleroma, "/pleroma/disable")