[task-193] [int]
This commit is contained in:
parent
b522514c26
commit
a73e11c6f6
6 changed files with 81 additions and 69 deletions
|
@ -18,10 +18,10 @@ namespace _espe.api
|
|||
/**
|
||||
*/
|
||||
export function register_invite_accept(
|
||||
rest_subject : lib_plankton.rest.type_rest
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
lib_plankton.rest_http.register<
|
||||
{
|
||||
key : string;
|
||||
membership_number_value : (null | string);
|
||||
|
@ -33,12 +33,12 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.post,
|
||||
"/invite/accept",
|
||||
_espe.api.full_path("/invite/accept"),
|
||||
{
|
||||
/**
|
||||
* @todo translation
|
||||
*/
|
||||
"description": "nimmt eine Einladung an",
|
||||
"description": () => "nimmt eine Einladung an",
|
||||
/**
|
||||
* @todo
|
||||
*/
|
||||
|
@ -51,8 +51,8 @@ namespace _espe.api
|
|||
"output_schema": () => ({
|
||||
"nullable": true,
|
||||
}),
|
||||
"restriction": restriction_none,
|
||||
"execution": async ({"input": input}) => {
|
||||
"restriction": () => restriction_none,
|
||||
"execution": () => async ({"input": input}) => {
|
||||
if (input === null) {
|
||||
return Promise.resolve({
|
||||
"status_code": 400,
|
||||
|
|
|
@ -19,10 +19,10 @@ namespace _espe.api
|
|||
/**
|
||||
*/
|
||||
export function register_invite_create(
|
||||
rest_subject : lib_plankton.rest.type_rest
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
lib_plankton.rest_http.register<
|
||||
{
|
||||
membership_number_mode : int;
|
||||
membership_number_value : (null | string);
|
||||
|
@ -46,12 +46,12 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.post,
|
||||
"/invite/create",
|
||||
_espe.api.full_path("/invite/create"),
|
||||
{
|
||||
/**
|
||||
* @todo translation
|
||||
*/
|
||||
"description": "erstellt eine Einladung und gibt die erzeugte ID und den erzeugten Schlüssel aus",
|
||||
"description": () => "erstellt eine Einladung und gibt die erzeugte ID und den erzeugten Schlüssel aus",
|
||||
"input_schema": () => ({
|
||||
"type": "object",
|
||||
"nullable": false,
|
||||
|
@ -145,8 +145,8 @@ namespace _espe.api
|
|||
"key",
|
||||
]
|
||||
}),
|
||||
"restriction": restriction_logged_in,
|
||||
"execution": async ({"input": input}) => {
|
||||
"restriction": () => restriction_logged_in,
|
||||
"execution": () => async ({"input": input}) => {
|
||||
if (input === null) {
|
||||
return Promise.reject(new Error("impossible"));
|
||||
}
|
||||
|
|
|
@ -18,25 +18,28 @@ namespace _espe.api
|
|||
/**
|
||||
*/
|
||||
export function register_invite_examine(
|
||||
rest_subject : lib_plankton.rest.type_rest
|
||||
rest_subject : lib_plankton.rest_http.type_rest
|
||||
) : void
|
||||
{
|
||||
register<
|
||||
lib_plankton.rest_http.register<
|
||||
any,
|
||||
any
|
||||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
"/invite/examine",
|
||||
_espe.api.full_path("/invite/examine"),
|
||||
{
|
||||
/**
|
||||
* @todo translation
|
||||
*/
|
||||
"description": "gibt die Daten einer Einladung anhand ihres Schlüssels aus",
|
||||
"input_schema": () => ({
|
||||
"type": "string",
|
||||
"nullable": false,
|
||||
}),
|
||||
"description": () => "gibt die Daten einer Einladung anhand ihres Schlüssels aus",
|
||||
"query_parameters": () => [
|
||||
{
|
||||
"name": "key",
|
||||
"required": true,
|
||||
"description": "key",
|
||||
}
|
||||
],
|
||||
"output_schema": () => ({
|
||||
"type": "object",
|
||||
"nullable": false,
|
||||
|
@ -77,7 +80,7 @@ namespace _espe.api
|
|||
"nullable": true,
|
||||
"description": "E-Mail-Adresse | Wert"
|
||||
},
|
||||
"groups_integer": {
|
||||
"groups_mode": {
|
||||
"type": "integer",
|
||||
"nullable": true,
|
||||
"description": "Gruppen | Modus"
|
||||
|
@ -104,9 +107,9 @@ namespace _espe.api
|
|||
"groups_value",
|
||||
]
|
||||
}),
|
||||
"restriction": restriction_none,
|
||||
"execution": ({"input": input}) => {
|
||||
const invite_key : _espe.type.invite_key = input;
|
||||
"restriction": () => restriction_none,
|
||||
"execution": () => ({"query_parameters": query_parameters, "input": input}) => {
|
||||
const invite_key : _espe.type.invite_key = query_parameters["key"];
|
||||
return (
|
||||
_espe.service.invite.examine(invite_key)
|
||||
.then(
|
||||
|
|
|
@ -271,7 +271,7 @@ namespace _espe
|
|||
"hidden": true,
|
||||
}),
|
||||
"conf_path": lib_plankton.args.class_argument.volatile({
|
||||
"indicators_long": ["conf_path"],
|
||||
"indicators_long": ["conf-path"],
|
||||
"indicators_short": ["c"],
|
||||
"type": lib_plankton.args.enum_type.string,
|
||||
"mode": lib_plankton.args.enum_mode.replace,
|
||||
|
|
|
@ -157,7 +157,9 @@ namespace _espe.repository.invite
|
|||
"groups_mode": _espe.helpers.invite_prefill_mode_decode(dispersal.core_row["groups_mode"]),
|
||||
"groups_value": lib_plankton.list.sorted<string>(
|
||||
dispersal.group_rows.map(row => row["group_name"]),
|
||||
(group1, group2) => ((group1 <= group2) ? 0 : 1)
|
||||
{
|
||||
"compare_element": (group1, group2) => (group1 <= group2)
|
||||
}
|
||||
),
|
||||
};
|
||||
}
|
||||
|
@ -280,6 +282,7 @@ namespace _espe.repository.invite
|
|||
|
||||
|
||||
/**
|
||||
* @todo optimize
|
||||
*/
|
||||
export async function identify(
|
||||
key : _espe.type.invite_key
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace _espe.service.invite
|
|||
{
|
||||
let invite_object : (null | _espe.type.invite_object);
|
||||
try {
|
||||
invite_object = await get(key)
|
||||
invite_object = await get(key);
|
||||
}
|
||||
catch (error) {
|
||||
invite_object = null;
|
||||
|
@ -122,7 +122,7 @@ namespace _espe.service.invite
|
|||
}
|
||||
else {
|
||||
const now : int = lib_plankton.base.get_current_timestamp(true);
|
||||
if ((invite_object.expiry !== null) && (invite_object.expiry >= now)) {
|
||||
if ((invite_object.expiry !== null) && (invite_object.expiry < now)) {
|
||||
return Promise.reject(new Error("expired"));
|
||||
}
|
||||
else {
|
||||
|
@ -146,47 +146,53 @@ namespace _espe.service.invite
|
|||
{
|
||||
const invite_id : _espe.type.invite_id = await _espe.repository.invite.identify(key);
|
||||
const invite_object : _espe.type.invite_object = await _espe.repository.invite.read(invite_id);
|
||||
const member_id : _espe.type.member_id = await _espe.service.member.project(
|
||||
{
|
||||
"membership_number": (
|
||||
(invite_object.membership_number_mode === _espe.type.invite_prefill_mode.free)
|
||||
?
|
||||
membership_number_value
|
||||
:
|
||||
invite_object.membership_number_value
|
||||
),
|
||||
"name_real_value": (
|
||||
(
|
||||
(invite_object.name_mode === _espe.type.invite_prefill_mode.free)
|
||||
&&
|
||||
(name_value !== null)
|
||||
)
|
||||
?
|
||||
name_value
|
||||
:
|
||||
invite_object.name_value
|
||||
),
|
||||
"email_address_private": (
|
||||
(
|
||||
(invite_object.email_address_mode === _espe.type.invite_prefill_mode.free)
|
||||
&&
|
||||
(email_address_value !== null)
|
||||
)
|
||||
?
|
||||
email_address_value
|
||||
:
|
||||
invite_object.email_address_value
|
||||
),
|
||||
"groups": (
|
||||
(invite_object.groups_mode === _espe.type.invite_prefill_mode.free)
|
||||
?
|
||||
groups_value
|
||||
:
|
||||
invite_object.groups_value
|
||||
),
|
||||
}
|
||||
);
|
||||
await _espe.repository.invite.delete_(invite_id);
|
||||
const now : int = lib_plankton.base.get_current_timestamp(true);
|
||||
if ((invite_object.expiry !== null) && (invite_object.expiry < now)) {
|
||||
return Promise.reject(new Error("expired"));
|
||||
}
|
||||
else {
|
||||
const member_id : _espe.type.member_id = await _espe.service.member.project(
|
||||
{
|
||||
"membership_number": (
|
||||
(invite_object.membership_number_mode === _espe.type.invite_prefill_mode.free)
|
||||
?
|
||||
membership_number_value
|
||||
:
|
||||
invite_object.membership_number_value
|
||||
),
|
||||
"name_real_value": (
|
||||
(
|
||||
(invite_object.name_mode === _espe.type.invite_prefill_mode.free)
|
||||
&&
|
||||
(name_value !== null)
|
||||
)
|
||||
?
|
||||
name_value
|
||||
:
|
||||
invite_object.name_value
|
||||
),
|
||||
"email_address_private": (
|
||||
(
|
||||
(invite_object.email_address_mode === _espe.type.invite_prefill_mode.free)
|
||||
&&
|
||||
(email_address_value !== null)
|
||||
)
|
||||
?
|
||||
email_address_value
|
||||
:
|
||||
invite_object.email_address_value
|
||||
),
|
||||
"groups": (
|
||||
(invite_object.groups_mode === _espe.type.invite_prefill_mode.free)
|
||||
?
|
||||
groups_value
|
||||
:
|
||||
invite_object.groups_value
|
||||
),
|
||||
}
|
||||
);
|
||||
await _espe.repository.invite.delete_(invite_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue