Adjusted yaml spec and fixed user interface for storing notification flags

This commit is contained in:
Daniel Schick 2024-12-05 17:25:01 +01:00
parent 941b5e70fb
commit 44f5d07ed7
5 changed files with 454 additions and 181 deletions

File diff suppressed because it is too large Load Diff

View File

@ -657,7 +657,7 @@ paths:
parameters:
- name: shipcall_id
in: query
required: true
required: false
description: '**Id of ship call**. *Example: 52*. Id given in ship call list'
schema:
$ref: '#/components/schemas/shipcallId'
@ -1545,9 +1545,11 @@ components:
id:
type: integer
example: 42
nullable: false
shipcall_id:
type: integer
example: 5
nullable: false
notification_type:
$ref: '#/components/schemas/NotificationType'
message:
@ -1567,8 +1569,8 @@ components:
example:
id: 42
shipcall_id: 5
notification_type: email
message: Entry XY violates rule Z
notification_type: next24h
message: Shipcall may be relevant to you in the next 24 hours
created: '2023-08-21T08:23:35Z'
modified: '2023-08-21T08:23:35Z'
notification_list:
@ -1579,13 +1581,13 @@ components:
example:
- id: 42
shipcall_id: 5
notification_type: email
notification_type: time_conflict
message: Entry XY violates rule Z
created: '2023-08-21T08:23:35Z'
modified: '2023-08-21T08:23:35Z'
- id: 43
shipcall_id: 7
notification_type: email
notification_type: time_conflict
message: Entry AB violates rule C
created: '2023-08-21T08:23:35Z'
modified: '2023-08-21T08:23:35Z'
@ -1804,10 +1806,11 @@ components:
type: string
description: Type of notification
enum:
- undefined
- email
- push
example: email
- assignment
- next24h
- time_conflict
- time_conflict_resolved
example: time_conflict
EvaluationType:
description: Evaluation of the ship call
readOnly: true

View File

@ -31,7 +31,11 @@ def GetUser(options):
"last_name": data[0].last_name,
"user_name": data[0].user_name,
"user_phone": data[0].user_phone,
"user_email": data[0].user_email
"user_email": data[0].user_email,
"notify_email": data[0].notify_email,
"notify_whatsapp": data[0].notify_whatsapp,
"notify_signal": data[0].notify_signal,
"notify_popup": data[0].notify_popup
}
token = jwt_handler.generate_jwt(payload=result, lifetime=120) # generate token valid 60 mins
result["token"] = token # add token to user data

View File

@ -35,7 +35,7 @@ def PutUser(schemaModel):
# should this be refactored?
# Also, what about the 'user_name'?
# 'participant_id' would also not trigger an update in isolation
if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel:
if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel or "notify_email" in schemaModel or "notify_whatsapp" in schemaModel or "notify_signal" in schemaModel or "notify_popup" in schemaModel:
# query = SQLQuery.get_user_put(schemaModel)
query = "UPDATE user SET "
isNotFirst = False

View File

@ -65,18 +65,16 @@ class EvaluationType(IntEnum):
return cls.undefined
class NotificationType(IntEnum):
"""
Any user has the attributes
'notify_email' -> NotificationType.email
'notify_popup' -> NotificationType.push
'notify_whatsapp' -> undeclared
'notify_signal' -> undeclared
This type is not the way the user is informed but the type of the notification, e.g. time conflict, time conflict resolved, etc.
It can be understood as an event type
"""
undefined = 0
email = 1
push = 2
# whatsapp = 3
# signal = 4
assignment = 0
next24h = 1
time_conflict = 2
time_conflict_resolved = 3
@classmethod
def _missing_(cls, value):
@ -489,7 +487,10 @@ class UserSchema(Schema):
user_email = fields.String(allow_none=True, required=False, validate=[validate.Length(max=64)])
old_password = fields.String(allow_none=True, required=False, validate=[validate.Length(max=128)])
new_password = fields.String(allow_none=True, required=False, validate=[validate.Length(min=6, max=128)])
# #TODO: the user schema does not (yet) include the 'notify_' fields
notify_email = fields.Bool(allow_none=True, required=False)
notify_whatsapp = fields.Bool(allow_none=True, required=False)
notify_signal = fields.Bool(allow_none=True, required=False)
notify_popup = fields.Bool(allow_none=True, required=False)
@validates("user_phone")
def validate_user_phone(self, value):
@ -542,10 +543,10 @@ class User:
user_phone: str
password_hash: str
api_key: str
notify_email: bool # #TODO_clarify: should we use an IntFlag for multi-assignment?
notify_whatsapp: bool # #TODO_clarify: should we use an IntFlag for multi-assignment?
notify_signal: bool # #TODO_clarify: should we use an IntFlag for multi-assignment?
notify_popup: bool # #TODO_clarify: should we use an IntFlag for multi-assignment?
notify_email: bool
notify_whatsapp: bool
notify_signal: bool
notify_popup: bool
created: datetime
modified: datetime