mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
145
src/things/message.ts
Normal file
145
src/things/message.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCMetaTranslations, SCTranslations} from '../general/i18n';
|
||||
import {SCISO8601Date} from '../general/time';
|
||||
import {
|
||||
SCCreativeWork,
|
||||
SCCreativeWorkMeta,
|
||||
SCCreativeWorkTranslatableProperties,
|
||||
SCCreativeWorkWithoutReferences,
|
||||
} from './abstract/creative-work';
|
||||
import {SCThingMeta, SCThingType} from './abstract/thing';
|
||||
import {SCThingThatCanBeOfferedTranslatableProperties} from './abstract/thing-that-can-be-offered';
|
||||
|
||||
/**
|
||||
* A message without references
|
||||
*/
|
||||
export interface SCMessageWithoutReferences
|
||||
extends SCCreativeWorkWithoutReferences {
|
||||
/**
|
||||
* Audience of the message
|
||||
*/
|
||||
audiences: SCMessageAudience[];
|
||||
|
||||
/**
|
||||
* When the message was created
|
||||
*/
|
||||
dateCreated?: SCISO8601Date;
|
||||
|
||||
/**
|
||||
* Message itself
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
messageBody: string;
|
||||
|
||||
/**
|
||||
* Translated fields of a message
|
||||
*/
|
||||
translations?: SCTranslations<SCMessageTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a message
|
||||
*/
|
||||
type: SCThingType.Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* A message
|
||||
*
|
||||
* @validatable
|
||||
* @indexable
|
||||
*/
|
||||
export interface SCMessage
|
||||
extends SCCreativeWork, SCMessageWithoutReferences {
|
||||
/**
|
||||
* Translated fields of a message
|
||||
*/
|
||||
translations?: SCTranslations<SCMessageTranslatableProperties>;
|
||||
|
||||
/**
|
||||
* Type of a message
|
||||
*/
|
||||
type: SCThingType.Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Audiences for messages
|
||||
*/
|
||||
export type SCMessageAudience =
|
||||
'students'
|
||||
| 'employees'
|
||||
| 'guests';
|
||||
|
||||
/**
|
||||
* Translatable properties of a message
|
||||
*/
|
||||
export interface SCMessageTranslatableProperties
|
||||
extends SCCreativeWorkTranslatableProperties, SCThingThatCanBeOfferedTranslatableProperties {
|
||||
/**
|
||||
* Message itself
|
||||
*
|
||||
* @text
|
||||
*/
|
||||
messageBody?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta information about messages
|
||||
*/
|
||||
export class SCMessageMeta
|
||||
extends SCThingMeta
|
||||
implements SCMetaTranslations<SCMessage> {
|
||||
/**
|
||||
* Translations of fields
|
||||
*/
|
||||
fieldTranslations = {
|
||||
de: {
|
||||
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
|
||||
.de,
|
||||
audiences: 'Zielgruppen',
|
||||
dateCreated: 'Erstellungsdatum',
|
||||
messageBody: 'Nachrichteninhalt',
|
||||
},
|
||||
en: {
|
||||
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>().fieldTranslations
|
||||
.en,
|
||||
audiences: 'audiences',
|
||||
dateCreated: 'date created',
|
||||
messageBody: 'message body',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Translations of values of fields
|
||||
*/
|
||||
fieldValueTranslations = {
|
||||
de: {
|
||||
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
|
||||
.fieldValueTranslations.de,
|
||||
audiences: {
|
||||
'employees': 'Angestellte',
|
||||
'guests': 'Gäste',
|
||||
'students': 'Studenten',
|
||||
},
|
||||
type: 'Nachricht',
|
||||
},
|
||||
en: {
|
||||
...SCCreativeWorkMeta.getInstance<SCCreativeWorkMeta>()
|
||||
.fieldValueTranslations.en,
|
||||
type: SCThingType.Message,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user