diff --git a/.cspell/nextcloud.txt b/.cspell/nextcloud.txt index fa54527f9f4..56b316bda39 100644 --- a/.cspell/nextcloud.txt +++ b/.cspell/nextcloud.txt @@ -1,3 +1,4 @@ +addressbook apirequest apppassword bigfilechunking diff --git a/packages/neon/neon_talk/lib/src/widgets/message.dart b/packages/neon/neon_talk/lib/src/widgets/message.dart index 42711f07ff8..5bdd9ce791b 100644 --- a/packages/neon/neon_talk/lib/src/widgets/message.dart +++ b/packages/neon/neon_talk/lib/src/widgets/message.dart @@ -119,40 +119,34 @@ InlineSpan buildRichObjectParameter({ required TextStyle? textStyle, required bool isPreview, }) { - Widget child; - - const mentionTypes = ['user', 'call', 'guest', 'user-group', 'group']; - if (mentionTypes.contains(parameter.type)) { - child = TalkRichObjectMention( - parameter: parameter, - textStyle: textStyle, - ); - } else { - if (isPreview) { - child = Text(parameter.name); - } else { - switch (parameter.type) { - case 'file': - child = TalkRichObjectFile( - parameter: parameter, - textStyle: textStyle, - ); - case 'deck-card': - child = TalkRichObjectDeckCard( - parameter: parameter, - ); - default: - child = TalkRichObjectFallback( - parameter: parameter, - textStyle: textStyle, - ); - } - } - } - return WidgetSpan( alignment: PlaceholderAlignment.middle, - child: child, + child: switch (parameter.type) { + spreed.RichObjectParameter_Type.user || + spreed.RichObjectParameter_Type.call || + spreed.RichObjectParameter_Type.guest || + spreed.RichObjectParameter_Type.userGroup || + spreed.RichObjectParameter_Type.group => + TalkRichObjectMention( + parameter: parameter, + textStyle: textStyle, + ), + _ => isPreview + ? Text(parameter.name) + : switch (parameter.type) { + spreed.RichObjectParameter_Type.file => TalkRichObjectFile( + parameter: parameter, + textStyle: textStyle, + ), + spreed.RichObjectParameter_Type.deckCard => TalkRichObjectDeckCard( + parameter: parameter, + ), + _ => TalkRichObjectFallback( + parameter: parameter, + textStyle: textStyle, + ), + }, + }, ); } diff --git a/packages/neon/neon_talk/lib/src/widgets/rich_object/file.dart b/packages/neon/neon_talk/lib/src/widgets/rich_object/file.dart index 4277e3f33bf..3d0f494ac85 100644 --- a/packages/neon/neon_talk/lib/src/widgets/rich_object/file.dart +++ b/packages/neon/neon_talk/lib/src/widgets/rich_object/file.dart @@ -27,7 +27,7 @@ class TalkRichObjectFile extends StatelessWidget { Widget build(BuildContext context) { Widget child; - if (parameter.previewAvailable == spreed.RichObjectParameter_PreviewAvailable.yes) { + if (parameter.previewAvailable == 'yes') { final maxHeight = MediaQuery.sizeOf(context).height / 2; var width = _parseDimension(parameter.width); diff --git a/packages/neon/neon_talk/lib/src/widgets/rich_object/mention.dart b/packages/neon/neon_talk/lib/src/widgets/rich_object/mention.dart index 1ebc1834046..7274c6b8c3b 100644 --- a/packages/neon/neon_talk/lib/src/widgets/rich_object/mention.dart +++ b/packages/neon/neon_talk/lib/src/widgets/rich_object/mention.dart @@ -27,7 +27,7 @@ class TalkRichObjectMention extends StatelessWidget { final bool highlight; switch (parameter.type) { - case 'user': + case spreed.RichObjectParameter_Type.user: final accountsBloc = NeonProvider.of(context); final account = accountsBloc.activeAccount.value!; @@ -36,7 +36,7 @@ class TalkRichObjectMention extends StatelessWidget { username: parameter.id, showStatus: false, ); - case 'call': + case spreed.RichObjectParameter_Type.call: highlight = true; child = CircleAvatar( child: ClipOval( @@ -45,13 +45,13 @@ class TalkRichObjectMention extends StatelessWidget { ), ), ); - case 'guest': + case spreed.RichObjectParameter_Type.guest: // TODO: Add highlighting when the mention is about the current guest user. highlight = false; child = CircleAvatar( child: Icon(AdaptiveIcons.person), ); - case 'user-group' || 'group': + case spreed.RichObjectParameter_Type.userGroup || spreed.RichObjectParameter_Type.group: final accountsBloc = NeonProvider.of(context); final userDetailsBloc = accountsBloc.activeUserDetailsBloc; final groups = userDetailsBloc.userDetails.valueOrNull?.data?.groups ?? BuiltList(); diff --git a/packages/neon/neon_talk/test/goldens/rich_object_mention_user_other.png b/packages/neon/neon_talk/test/goldens/rich_object_mention_user_other.png index 85db89a344d..a6a25550377 100644 Binary files a/packages/neon/neon_talk/test/goldens/rich_object_mention_user_other.png and b/packages/neon/neon_talk/test/goldens/rich_object_mention_user_other.png differ diff --git a/packages/neon/neon_talk/test/message_test.dart b/packages/neon/neon_talk/test/message_test.dart index d505237cd8b..6a7054a742f 100644 --- a/packages/neon/neon_talk/test/message_test.dart +++ b/packages/neon/neon_talk/test/message_test.dart @@ -696,8 +696,14 @@ void main() { for (final isPreview in [true, false]) { group(isPreview ? 'As preview' : 'Complete', () { group('Mention', () { - for (final type in ['user', 'call', 'guest', 'user-group', 'group']) { - testWidgets(type, (tester) async { + for (final type in [ + spreed.RichObjectParameter_Type.user, + spreed.RichObjectParameter_Type.call, + spreed.RichObjectParameter_Type.guest, + spreed.RichObjectParameter_Type.userGroup, + spreed.RichObjectParameter_Type.group, + ]) { + testWidgets(type.value, (tester) async { final userDetails = MockUserDetails(); when(() => userDetails.groups).thenReturn(BuiltList()); @@ -749,7 +755,7 @@ void main() { text: buildRichObjectParameter( parameter: spreed.RichObjectParameter( (b) => b - ..type = 'file' + ..type = spreed.RichObjectParameter_Type.file ..id = '' ..name = 'name', ), @@ -771,7 +777,7 @@ void main() { text: buildRichObjectParameter( parameter: spreed.RichObjectParameter( (b) => b - ..type = 'deck-card' + ..type = spreed.RichObjectParameter_Type.deckCard ..id = '' ..name = 'name' ..boardname = 'boardname' @@ -795,7 +801,7 @@ void main() { text: buildRichObjectParameter( parameter: spreed.RichObjectParameter( (b) => b - ..type = 'unknown' + ..type = spreed.RichObjectParameter_Type.addressbook ..id = '' ..name = 'name', ), @@ -836,7 +842,7 @@ void main() { BuiltMap({ type: spreed.RichObjectParameter( (b) => b - ..type = '' + ..type = spreed.RichObjectParameter_Type.user ..id = '' ..name = '', ), @@ -856,7 +862,7 @@ void main() { BuiltMap({ 'file': spreed.RichObjectParameter( (b) => b - ..type = 'file' + ..type = spreed.RichObjectParameter_Type.file ..id = '' ..name = '', ), @@ -878,13 +884,13 @@ void main() { BuiltMap({ 'actor1': spreed.RichObjectParameter( (b) => b - ..type = 'user' + ..type = spreed.RichObjectParameter_Type.user ..id = '' ..name = '', ), 'actor2': spreed.RichObjectParameter( (b) => b - ..type = 'user' + ..type = spreed.RichObjectParameter_Type.user ..id = '' ..name = '', ), diff --git a/packages/neon/neon_talk/test/rich_object_test.dart b/packages/neon/neon_talk/test/rich_object_test.dart index 0c0fa260043..eea8d9ec380 100644 --- a/packages/neon/neon_talk/test/rich_object_test.dart +++ b/packages/neon/neon_talk/test/rich_object_test.dart @@ -48,7 +48,7 @@ void main() { child: TalkRichObjectDeckCard( parameter: spreed.RichObjectParameter( (b) => b - ..type = '' + ..type = spreed.RichObjectParameter_Type.deckCard ..id = '' ..name = 'name' ..boardname = 'boardname' @@ -75,7 +75,7 @@ void main() { child: TalkRichObjectMention( parameter: spreed.RichObjectParameter( (b) => b - ..type = 'user' + ..type = spreed.RichObjectParameter_Type.user ..id = 'username' ..name = 'name', ), @@ -95,14 +95,17 @@ void main() { providers: [ NeonProvider.value(value: accountsBloc), ], - child: TalkRichObjectMention( - parameter: spreed.RichObjectParameter( - (b) => b - ..type = 'user' - ..id = 'other' - ..name = 'name', + child: NeonProvider.value( + value: accountsBloc, + child: TalkRichObjectMention( + parameter: spreed.RichObjectParameter( + (b) => b + ..type = spreed.RichObjectParameter_Type.user + ..id = 'other' + ..name = 'name', + ), + textStyle: null, ), - textStyle: null, ), ), ); @@ -120,15 +123,18 @@ void main() { providers: [ NeonProvider.value(value: accountsBloc), ], - child: TalkRichObjectMention( - parameter: spreed.RichObjectParameter( - (b) => b - ..type = 'call' - ..id = '' - ..name = 'name' - ..iconUrl = '', + child: NeonProvider.value( + value: accountsBloc, + child: TalkRichObjectMention( + parameter: spreed.RichObjectParameter( + (b) => b + ..type = spreed.RichObjectParameter_Type.call + ..id = '' + ..name = 'name' + ..iconUrl = '', + ), + textStyle: null, ), - textStyle: null, ), ), ); @@ -146,7 +152,7 @@ void main() { child: TalkRichObjectMention( parameter: spreed.RichObjectParameter( (b) => b - ..type = 'guest' + ..type = spreed.RichObjectParameter_Type.guest ..id = '' ..name = 'name', ), @@ -162,8 +168,11 @@ void main() { ); }); - for (final type in ['user-group', 'group']) { - testWidgets(type, (tester) async { + for (final type in [ + spreed.RichObjectParameter_Type.userGroup, + spreed.RichObjectParameter_Type.group, + ]) { + testWidgets(type.value, (tester) async { final userDetails = MockUserDetails(); when(() => userDetails.groups).thenReturn(BuiltList(['group'])); @@ -192,7 +201,7 @@ void main() { expect(find.text('name'), findsOne); await expectLater( find.byType(TalkRichObjectMention), - matchesGoldenFile('goldens/rich_object_mention_${type}_highlight.png'), + matchesGoldenFile('goldens/rich_object_mention_${type.value}_highlight.png'), ); await tester.pumpWidget( @@ -215,7 +224,7 @@ void main() { expect(find.text('name'), findsOne); await expectLater( find.byType(TalkRichObjectMention), - matchesGoldenFile('goldens/rich_object_mention_${type}_other.png'), + matchesGoldenFile('goldens/rich_object_mention_${type.value}_other.png'), ); }); } @@ -228,16 +237,19 @@ void main() { providers: [ NeonProvider.value(value: accountsBloc), ], - child: TalkRichObjectFile( - parameter: spreed.RichObjectParameter( - (b) => b - ..type = '' - ..id = '0' - ..name = 'name' - ..previewAvailable = spreed.RichObjectParameter_PreviewAvailable.yes - ..path = '', + child: NeonProvider.value( + value: accountsBloc, + child: TalkRichObjectFile( + parameter: spreed.RichObjectParameter( + (b) => b + ..type = spreed.RichObjectParameter_Type.file + ..id = '0' + ..name = 'name' + ..previewAvailable = 'yes' + ..path = '', + ), + textStyle: null, ), - textStyle: null, ), ), ); @@ -255,10 +267,10 @@ void main() { child: TalkRichObjectFile( parameter: spreed.RichObjectParameter( (b) => b - ..type = '' + ..type = spreed.RichObjectParameter_Type.file ..id = '0' ..name = 'name' - ..previewAvailable = spreed.RichObjectParameter_PreviewAvailable.no + ..previewAvailable = 'no' ..path = '', ), textStyle: null, @@ -281,7 +293,7 @@ void main() { child: TalkRichObjectFallback( parameter: spreed.RichObjectParameter( (b) => b - ..type = '' + ..type = spreed.RichObjectParameter_Type.addressbook ..id = '' ..name = 'name', ), @@ -306,7 +318,7 @@ void main() { child: TalkRichObjectFallback( parameter: spreed.RichObjectParameter( (b) => b - ..type = '' + ..type = spreed.RichObjectParameter_Type.addressbook ..id = '' ..name = 'name' ..iconUrl = '', diff --git a/packages/nextcloud/lib/src/api/spreed.openapi.dart b/packages/nextcloud/lib/src/api/spreed.openapi.dart index 3db1d0588e0..5fe16610292 100644 --- a/packages/nextcloud/lib/src/api/spreed.openapi.dart +++ b/packages/nextcloud/lib/src/api/spreed.openapi.dart @@ -16028,261 +16028,181 @@ class _$ActorTypeSerializer implements PrimitiveSerializer { _fromWire[serialized]!; } -class RichObjectParameter_CallType extends EnumClass { - const RichObjectParameter_CallType._(super.name); +class RichObjectParameter_Type extends EnumClass { + const RichObjectParameter_Type._(super.name); - /// `one2one` - static const RichObjectParameter_CallType one2one = _$richObjectParameterCallTypeOne2one; + /// `addressbook` + static const RichObjectParameter_Type addressbook = _$richObjectParameterTypeAddressbook; - /// `group` - static const RichObjectParameter_CallType group = _$richObjectParameterCallTypeGroup; - - /// `public` - static const RichObjectParameter_CallType public = _$richObjectParameterCallTypePublic; - - /// Returns a set with all values this enum contains. - // coverage:ignore-start - static BuiltSet get values => _$richObjectParameterCallTypeValues; - // coverage:ignore-end - - /// Returns the enum value associated to the [name]. - static RichObjectParameter_CallType valueOf(String name) => _$valueOfRichObjectParameter_CallType(name); - - /// Returns the serialized value of this enum value. - String get value => _$jsonSerializers.serializeWith(serializer, this)! as String; - - /// Serializer for RichObjectParameter_CallType. - @BuiltValueSerializer(custom: true) - static Serializer get serializer => const _$RichObjectParameter_CallTypeSerializer(); -} - -class _$RichObjectParameter_CallTypeSerializer implements PrimitiveSerializer { - const _$RichObjectParameter_CallTypeSerializer(); - - static const Map _toWire = { - RichObjectParameter_CallType.one2one: 'one2one', - RichObjectParameter_CallType.group: 'group', - RichObjectParameter_CallType.public: 'public', - }; - - static const Map _fromWire = { - 'one2one': RichObjectParameter_CallType.one2one, - 'group': RichObjectParameter_CallType.group, - 'public': RichObjectParameter_CallType.public, - }; - - @override - Iterable get types => const [RichObjectParameter_CallType]; - - @override - String get wireName => 'RichObjectParameter_CallType'; - - @override - Object serialize( - Serializers serializers, - RichObjectParameter_CallType object, { - FullType specifiedType = FullType.unspecified, - }) => - _toWire[object]!; - - @override - RichObjectParameter_CallType deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) => - _fromWire[serialized]!; -} - -typedef RichObjectParameter_Size = ({int? $int, String? string}); - -class RichObjectParameter_PreviewAvailable extends EnumClass { - const RichObjectParameter_PreviewAvailable._(super.name); + /// `addressbook-contact` + @BuiltValueEnumConst(wireName: 'addressbook-contact') + static const RichObjectParameter_Type addressbookContact = _$richObjectParameterTypeAddressbookContact; - /// `yes` - static const RichObjectParameter_PreviewAvailable yes = _$richObjectParameterPreviewAvailableYes; + /// `announcement` + static const RichObjectParameter_Type announcement = _$richObjectParameterTypeAnnouncement; - /// `no` - static const RichObjectParameter_PreviewAvailable no = _$richObjectParameterPreviewAvailableNo; + /// `app` + static const RichObjectParameter_Type app = _$richObjectParameterTypeApp; - /// Returns a set with all values this enum contains. - // coverage:ignore-start - static BuiltSet get values => _$richObjectParameterPreviewAvailableValues; - // coverage:ignore-end + /// `calendar` + static const RichObjectParameter_Type calendar = _$richObjectParameterTypeCalendar; - /// Returns the enum value associated to the [name]. - static RichObjectParameter_PreviewAvailable valueOf(String name) => - _$valueOfRichObjectParameter_PreviewAvailable(name); + /// `calendar-event` + @BuiltValueEnumConst(wireName: 'calendar-event') + static const RichObjectParameter_Type calendarEvent = _$richObjectParameterTypeCalendarEvent; - /// Returns the serialized value of this enum value. - String get value => _$jsonSerializers.serializeWith(serializer, this)! as String; - - /// Serializer for RichObjectParameter_PreviewAvailable. - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - const _$RichObjectParameter_PreviewAvailableSerializer(); -} - -class _$RichObjectParameter_PreviewAvailableSerializer - implements PrimitiveSerializer { - const _$RichObjectParameter_PreviewAvailableSerializer(); - - static const Map _toWire = - { - RichObjectParameter_PreviewAvailable.yes: 'yes', - RichObjectParameter_PreviewAvailable.no: 'no', - }; - - static const Map _fromWire = - { - 'yes': RichObjectParameter_PreviewAvailable.yes, - 'no': RichObjectParameter_PreviewAvailable.no, - }; - - @override - Iterable get types => const [RichObjectParameter_PreviewAvailable]; - - @override - String get wireName => 'RichObjectParameter_PreviewAvailable'; - - @override - Object serialize( - Serializers serializers, - RichObjectParameter_PreviewAvailable object, { - FullType specifiedType = FullType.unspecified, - }) => - _toWire[object]!; + /// `call` + static const RichObjectParameter_Type call = _$richObjectParameterTypeCall; - @override - RichObjectParameter_PreviewAvailable deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) => - _fromWire[serialized]!; -} + /// `circle` + static const RichObjectParameter_Type circle = _$richObjectParameterTypeCircle; -class RichObjectParameter_Visibility extends EnumClass { - const RichObjectParameter_Visibility._(super.name); + /// `deck-board` + @BuiltValueEnumConst(wireName: 'deck-board') + static const RichObjectParameter_Type deckBoard = _$richObjectParameterTypeDeckBoard; - /// `0` - @BuiltValueEnumConst(wireName: '0') - static const RichObjectParameter_Visibility $0 = _$richObjectParameterVisibility$0; + /// `deck-card` + @BuiltValueEnumConst(wireName: 'deck-card') + static const RichObjectParameter_Type deckCard = _$richObjectParameterTypeDeckCard; - /// `1` - @BuiltValueEnumConst(wireName: '1') - static const RichObjectParameter_Visibility $1 = _$richObjectParameterVisibility$1; + /// `email` + static const RichObjectParameter_Type email = _$richObjectParameterTypeEmail; - /// Returns a set with all values this enum contains. - // coverage:ignore-start - static BuiltSet get values => _$richObjectParameterVisibilityValues; - // coverage:ignore-end + /// `file` + static const RichObjectParameter_Type file = _$richObjectParameterTypeFile; - /// Returns the enum value associated to the [name]. - static RichObjectParameter_Visibility valueOf(String name) => _$valueOfRichObjectParameter_Visibility(name); + /// `forms-form` + @BuiltValueEnumConst(wireName: 'forms-form') + static const RichObjectParameter_Type formsForm = _$richObjectParameterTypeFormsForm; - /// Returns the serialized value of this enum value. - String get value => _$jsonSerializers.serializeWith(serializer, this)! as String; + /// `guest` + static const RichObjectParameter_Type guest = _$richObjectParameterTypeGuest; - /// Serializer for RichObjectParameter_Visibility. - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - const _$RichObjectParameter_VisibilitySerializer(); -} + /// `highlight` + static const RichObjectParameter_Type highlight = _$richObjectParameterTypeHighlight; -class _$RichObjectParameter_VisibilitySerializer implements PrimitiveSerializer { - const _$RichObjectParameter_VisibilitySerializer(); + /// `geo-location` + @BuiltValueEnumConst(wireName: 'geo-location') + static const RichObjectParameter_Type geoLocation = _$richObjectParameterTypeGeoLocation; - static const Map _toWire = { - RichObjectParameter_Visibility.$0: '0', - RichObjectParameter_Visibility.$1: '1', - }; + /// `open-graph` + @BuiltValueEnumConst(wireName: 'open-graph') + static const RichObjectParameter_Type openGraph = _$richObjectParameterTypeOpenGraph; - static const Map _fromWire = { - '0': RichObjectParameter_Visibility.$0, - '1': RichObjectParameter_Visibility.$1, - }; + /// `pending-federated-share` + @BuiltValueEnumConst(wireName: 'pending-federated-share') + static const RichObjectParameter_Type pendingFederatedShare = _$richObjectParameterTypePendingFederatedShare; - @override - Iterable get types => const [RichObjectParameter_Visibility]; + /// `systemtag` + static const RichObjectParameter_Type systemtag = _$richObjectParameterTypeSystemtag; - @override - String get wireName => 'RichObjectParameter_Visibility'; + /// `talk-attachment` + @BuiltValueEnumConst(wireName: 'talk-attachment') + static const RichObjectParameter_Type talkAttachment = _$richObjectParameterTypeTalkAttachment; - @override - Object serialize( - Serializers serializers, - RichObjectParameter_Visibility object, { - FullType specifiedType = FullType.unspecified, - }) => - _toWire[object]!; + /// `talk-poll` + @BuiltValueEnumConst(wireName: 'talk-poll') + static const RichObjectParameter_Type talkPoll = _$richObjectParameterTypeTalkPoll; - @override - RichObjectParameter_Visibility deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) => - _fromWire[serialized]!; -} + /// `user` + static const RichObjectParameter_Type user = _$richObjectParameterTypeUser; -class RichObjectParameter_Assignable extends EnumClass { - const RichObjectParameter_Assignable._(super.name); + /// `user-group` + @BuiltValueEnumConst(wireName: 'user-group') + static const RichObjectParameter_Type userGroup = _$richObjectParameterTypeUserGroup; - /// `0` - @BuiltValueEnumConst(wireName: '0') - static const RichObjectParameter_Assignable $0 = _$richObjectParameterAssignable$0; - - /// `1` - @BuiltValueEnumConst(wireName: '1') - static const RichObjectParameter_Assignable $1 = _$richObjectParameterAssignable$1; + /// `group` + static const RichObjectParameter_Type group = _$richObjectParameterTypeGroup; /// Returns a set with all values this enum contains. // coverage:ignore-start - static BuiltSet get values => _$richObjectParameterAssignableValues; + static BuiltSet get values => _$richObjectParameterTypeValues; // coverage:ignore-end /// Returns the enum value associated to the [name]. - static RichObjectParameter_Assignable valueOf(String name) => _$valueOfRichObjectParameter_Assignable(name); + static RichObjectParameter_Type valueOf(String name) => _$valueOfRichObjectParameter_Type(name); /// Returns the serialized value of this enum value. String get value => _$jsonSerializers.serializeWith(serializer, this)! as String; - /// Serializer for RichObjectParameter_Assignable. + /// Serializer for RichObjectParameter_Type. @BuiltValueSerializer(custom: true) - static Serializer get serializer => - const _$RichObjectParameter_AssignableSerializer(); -} - -class _$RichObjectParameter_AssignableSerializer implements PrimitiveSerializer { - const _$RichObjectParameter_AssignableSerializer(); - - static const Map _toWire = { - RichObjectParameter_Assignable.$0: '0', - RichObjectParameter_Assignable.$1: '1', - }; - - static const Map _fromWire = { - '0': RichObjectParameter_Assignable.$0, - '1': RichObjectParameter_Assignable.$1, - }; - - @override - Iterable get types => const [RichObjectParameter_Assignable]; - - @override - String get wireName => 'RichObjectParameter_Assignable'; + static Serializer get serializer => const _$RichObjectParameter_TypeSerializer(); +} + +class _$RichObjectParameter_TypeSerializer implements PrimitiveSerializer { + const _$RichObjectParameter_TypeSerializer(); + + static const Map _toWire = { + RichObjectParameter_Type.addressbook: 'addressbook', + RichObjectParameter_Type.addressbookContact: 'addressbook-contact', + RichObjectParameter_Type.announcement: 'announcement', + RichObjectParameter_Type.app: 'app', + RichObjectParameter_Type.calendar: 'calendar', + RichObjectParameter_Type.calendarEvent: 'calendar-event', + RichObjectParameter_Type.call: 'call', + RichObjectParameter_Type.circle: 'circle', + RichObjectParameter_Type.deckBoard: 'deck-board', + RichObjectParameter_Type.deckCard: 'deck-card', + RichObjectParameter_Type.email: 'email', + RichObjectParameter_Type.file: 'file', + RichObjectParameter_Type.formsForm: 'forms-form', + RichObjectParameter_Type.guest: 'guest', + RichObjectParameter_Type.highlight: 'highlight', + RichObjectParameter_Type.geoLocation: 'geo-location', + RichObjectParameter_Type.openGraph: 'open-graph', + RichObjectParameter_Type.pendingFederatedShare: 'pending-federated-share', + RichObjectParameter_Type.systemtag: 'systemtag', + RichObjectParameter_Type.talkAttachment: 'talk-attachment', + RichObjectParameter_Type.talkPoll: 'talk-poll', + RichObjectParameter_Type.user: 'user', + RichObjectParameter_Type.userGroup: 'user-group', + RichObjectParameter_Type.group: 'group', + }; + + static const Map _fromWire = { + 'addressbook': RichObjectParameter_Type.addressbook, + 'addressbook-contact': RichObjectParameter_Type.addressbookContact, + 'announcement': RichObjectParameter_Type.announcement, + 'app': RichObjectParameter_Type.app, + 'calendar': RichObjectParameter_Type.calendar, + 'calendar-event': RichObjectParameter_Type.calendarEvent, + 'call': RichObjectParameter_Type.call, + 'circle': RichObjectParameter_Type.circle, + 'deck-board': RichObjectParameter_Type.deckBoard, + 'deck-card': RichObjectParameter_Type.deckCard, + 'email': RichObjectParameter_Type.email, + 'file': RichObjectParameter_Type.file, + 'forms-form': RichObjectParameter_Type.formsForm, + 'guest': RichObjectParameter_Type.guest, + 'highlight': RichObjectParameter_Type.highlight, + 'geo-location': RichObjectParameter_Type.geoLocation, + 'open-graph': RichObjectParameter_Type.openGraph, + 'pending-federated-share': RichObjectParameter_Type.pendingFederatedShare, + 'systemtag': RichObjectParameter_Type.systemtag, + 'talk-attachment': RichObjectParameter_Type.talkAttachment, + 'talk-poll': RichObjectParameter_Type.talkPoll, + 'user': RichObjectParameter_Type.user, + 'user-group': RichObjectParameter_Type.userGroup, + 'group': RichObjectParameter_Type.group, + }; + + @override + Iterable get types => const [RichObjectParameter_Type]; + + @override + String get wireName => 'RichObjectParameter_Type'; @override Object serialize( Serializers serializers, - RichObjectParameter_Assignable object, { + RichObjectParameter_Type object, { FullType specifiedType = FullType.unspecified, }) => _toWire[object]!; @override - RichObjectParameter_Assignable deserialize( + RichObjectParameter_Type deserialize( Serializers serializers, Object serialized, { FullType specifiedType = FullType.unspecified, @@ -16290,18 +16210,18 @@ class _$RichObjectParameter_AssignableSerializer implements PrimitiveSerializer< _fromWire[serialized]!; } +typedef RichObjectParameter_Size = ({int? $int, String? string}); typedef RichObjectParameter_Width = ({int? $int, String? string}); typedef RichObjectParameter_Height = ({int? $int, String? string}); @BuiltValue(instantiable: false) abstract interface class $RichObjectParameterInterface { - String get type; + RichObjectParameter_Type get type; String get id; String get name; - String? get server; String? get link; @BuiltValueField(wireName: 'call-type') - RichObjectParameter_CallType? get callType; + String? get callType; @BuiltValueField(wireName: 'icon-url') String? get iconUrl; @BuiltValueField(wireName: 'message-id') @@ -16312,16 +16232,17 @@ abstract interface class $RichObjectParameterInterface { String? get path; String? get mimetype; @BuiltValueField(wireName: 'preview-available') - RichObjectParameter_PreviewAvailable? get previewAvailable; + String? get previewAvailable; String? get mtime; String? get latitude; String? get longitude; String? get description; String? get thumb; String? get website; - RichObjectParameter_Visibility? get visibility; - RichObjectParameter_Assignable? get assignable; + String? get visibility; + String? get assignable; String? get conversation; + String? get server; String? get etag; RichObjectParameter_Width? get width; RichObjectParameter_Height? get height; @@ -42872,11 +42793,8 @@ final Serializers _$serializers = (Serializers().toBuilder() ..add(BaseMessage.serializer) ..addBuilderFactory(const FullType(RichObjectParameter), RichObjectParameterBuilder.new) ..add(RichObjectParameter.serializer) - ..add(RichObjectParameter_CallType.serializer) + ..add(RichObjectParameter_Type.serializer) ..add($b2c4857c0136baea42828d89c87c757dExtension._serializer) - ..add(RichObjectParameter_PreviewAvailable.serializer) - ..add(RichObjectParameter_Visibility.serializer) - ..add(RichObjectParameter_Assignable.serializer) ..addBuilderFactory( const FullType(BuiltMap, [FullType(String), FullType(RichObjectParameter)]), MapBuilder.new, diff --git a/packages/nextcloud/lib/src/api/spreed.openapi.g.dart b/packages/nextcloud/lib/src/api/spreed.openapi.g.dart index df486b625eb..f1941545c0b 100644 --- a/packages/nextcloud/lib/src/api/spreed.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/spreed.openapi.g.dart @@ -105,90 +105,114 @@ final BuiltSet _$actorTypeValues = BuiltSet(const _$richObjectParameterCallTypeValues = - BuiltSet(const [ - _$richObjectParameterCallTypeOne2one, - _$richObjectParameterCallTypeGroup, - _$richObjectParameterCallTypePublic, -]); - -const RichObjectParameter_PreviewAvailable _$richObjectParameterPreviewAvailableYes = - RichObjectParameter_PreviewAvailable._('yes'); -const RichObjectParameter_PreviewAvailable _$richObjectParameterPreviewAvailableNo = - RichObjectParameter_PreviewAvailable._('no'); - -RichObjectParameter_PreviewAvailable _$valueOfRichObjectParameter_PreviewAvailable(String name) { - switch (name) { - case 'yes': - return _$richObjectParameterPreviewAvailableYes; - case 'no': - return _$richObjectParameterPreviewAvailableNo; - default: - throw ArgumentError(name); - } -} - -final BuiltSet _$richObjectParameterPreviewAvailableValues = - BuiltSet(const [ - _$richObjectParameterPreviewAvailableYes, - _$richObjectParameterPreviewAvailableNo, -]); - -const RichObjectParameter_Visibility _$richObjectParameterVisibility$0 = RichObjectParameter_Visibility._('\$0'); -const RichObjectParameter_Visibility _$richObjectParameterVisibility$1 = RichObjectParameter_Visibility._('\$1'); - -RichObjectParameter_Visibility _$valueOfRichObjectParameter_Visibility(String name) { - switch (name) { - case '\$0': - return _$richObjectParameterVisibility$0; - case '\$1': - return _$richObjectParameterVisibility$1; + return _$richObjectParameterTypeGroup; default: throw ArgumentError(name); } } -final BuiltSet _$richObjectParameterVisibilityValues = - BuiltSet(const [ - _$richObjectParameterVisibility$0, - _$richObjectParameterVisibility$1, -]); - -const RichObjectParameter_Assignable _$richObjectParameterAssignable$0 = RichObjectParameter_Assignable._('\$0'); -const RichObjectParameter_Assignable _$richObjectParameterAssignable$1 = RichObjectParameter_Assignable._('\$1'); - -RichObjectParameter_Assignable _$valueOfRichObjectParameter_Assignable(String name) { - switch (name) { - case '\$0': - return _$richObjectParameterAssignable$0; - case '\$1': - return _$richObjectParameterAssignable$1; - default: - throw ArgumentError(name); - } -} - -final BuiltSet _$richObjectParameterAssignableValues = - BuiltSet(const [ - _$richObjectParameterAssignable$0, - _$richObjectParameterAssignable$1, +final BuiltSet _$richObjectParameterTypeValues = + BuiltSet(const [ + _$richObjectParameterTypeAddressbook, + _$richObjectParameterTypeAddressbookContact, + _$richObjectParameterTypeAnnouncement, + _$richObjectParameterTypeApp, + _$richObjectParameterTypeCalendar, + _$richObjectParameterTypeCalendarEvent, + _$richObjectParameterTypeCall, + _$richObjectParameterTypeCircle, + _$richObjectParameterTypeDeckBoard, + _$richObjectParameterTypeDeckCard, + _$richObjectParameterTypeEmail, + _$richObjectParameterTypeFile, + _$richObjectParameterTypeFormsForm, + _$richObjectParameterTypeGuest, + _$richObjectParameterTypeHighlight, + _$richObjectParameterTypeGeoLocation, + _$richObjectParameterTypeOpenGraph, + _$richObjectParameterTypePendingFederatedShare, + _$richObjectParameterTypeSystemtag, + _$richObjectParameterTypeTalkAttachment, + _$richObjectParameterTypeTalkPoll, + _$richObjectParameterTypeUser, + _$richObjectParameterTypeUserGroup, + _$richObjectParameterTypeGroup, ]); const MessageType _$messageTypeComment = MessageType._('comment'); @@ -3795,19 +3819,13 @@ class _$RichObjectParameterSerializer implements StructuredSerializer[ 'type', - serializers.serialize(object.type, specifiedType: const FullType(String)), + serializers.serialize(object.type, specifiedType: const FullType(RichObjectParameter_Type)), 'id', serializers.serialize(object.id, specifiedType: const FullType(String)), 'name', serializers.serialize(object.name, specifiedType: const FullType(String)), ]; Object? value; - value = object.server; - if (value != null) { - result - ..add('server') - ..add(serializers.serialize(value, specifiedType: const FullType(String))); - } value = object.link; if (value != null) { result @@ -3818,7 +3836,7 @@ class _$RichObjectParameterSerializer implements StructuredSerializer, $OCSMetaInterf abstract mixin class $RichObjectParameterInterfaceBuilder { void replace($RichObjectParameterInterface other); void update(void Function($RichObjectParameterInterfaceBuilder) updates); - String? get type; - set type(String? type); + RichObjectParameter_Type? get type; + set type(RichObjectParameter_Type? type); String? get id; set id(String? id); @@ -19592,14 +19612,11 @@ abstract mixin class $RichObjectParameterInterfaceBuilder { String? get name; set name(String? name); - String? get server; - set server(String? server); - String? get link; set link(String? link); - RichObjectParameter_CallType? get callType; - set callType(RichObjectParameter_CallType? callType); + String? get callType; + set callType(String? callType); String? get iconUrl; set iconUrl(String? iconUrl); @@ -19622,8 +19639,8 @@ abstract mixin class $RichObjectParameterInterfaceBuilder { String? get mimetype; set mimetype(String? mimetype); - RichObjectParameter_PreviewAvailable? get previewAvailable; - set previewAvailable(RichObjectParameter_PreviewAvailable? previewAvailable); + String? get previewAvailable; + set previewAvailable(String? previewAvailable); String? get mtime; set mtime(String? mtime); @@ -19643,15 +19660,18 @@ abstract mixin class $RichObjectParameterInterfaceBuilder { String? get website; set website(String? website); - RichObjectParameter_Visibility? get visibility; - set visibility(RichObjectParameter_Visibility? visibility); + String? get visibility; + set visibility(String? visibility); - RichObjectParameter_Assignable? get assignable; - set assignable(RichObjectParameter_Assignable? assignable); + String? get assignable; + set assignable(String? assignable); String? get conversation; set conversation(String? conversation); + String? get server; + set server(String? server); + String? get etag; set etag(String? etag); @@ -19664,17 +19684,15 @@ abstract mixin class $RichObjectParameterInterfaceBuilder { class _$RichObjectParameter extends RichObjectParameter { @override - final String type; + final RichObjectParameter_Type type; @override final String id; @override final String name; @override - final String? server; - @override final String? link; @override - final RichObjectParameter_CallType? callType; + final String? callType; @override final String? iconUrl; @override @@ -19690,7 +19708,7 @@ class _$RichObjectParameter extends RichObjectParameter { @override final String? mimetype; @override - final RichObjectParameter_PreviewAvailable? previewAvailable; + final String? previewAvailable; @override final String? mtime; @override @@ -19704,12 +19722,14 @@ class _$RichObjectParameter extends RichObjectParameter { @override final String? website; @override - final RichObjectParameter_Visibility? visibility; + final String? visibility; @override - final RichObjectParameter_Assignable? assignable; + final String? assignable; @override final String? conversation; @override + final String? server; + @override final String? etag; @override final RichObjectParameter_Width? width; @@ -19723,7 +19743,6 @@ class _$RichObjectParameter extends RichObjectParameter { {required this.type, required this.id, required this.name, - this.server, this.link, this.callType, this.iconUrl, @@ -19743,6 +19762,7 @@ class _$RichObjectParameter extends RichObjectParameter { this.visibility, this.assignable, this.conversation, + this.server, this.etag, this.width, this.height}) @@ -19767,7 +19787,6 @@ class _$RichObjectParameter extends RichObjectParameter { type == other.type && id == other.id && name == other.name && - server == other.server && link == other.link && callType == other.callType && iconUrl == other.iconUrl && @@ -19787,6 +19806,7 @@ class _$RichObjectParameter extends RichObjectParameter { visibility == other.visibility && assignable == other.assignable && conversation == other.conversation && + server == other.server && etag == other.etag && width == _$dynamicOther.width && height == _$dynamicOther.height; @@ -19798,7 +19818,6 @@ class _$RichObjectParameter extends RichObjectParameter { _$hash = $jc(_$hash, type.hashCode); _$hash = $jc(_$hash, id.hashCode); _$hash = $jc(_$hash, name.hashCode); - _$hash = $jc(_$hash, server.hashCode); _$hash = $jc(_$hash, link.hashCode); _$hash = $jc(_$hash, callType.hashCode); _$hash = $jc(_$hash, iconUrl.hashCode); @@ -19818,6 +19837,7 @@ class _$RichObjectParameter extends RichObjectParameter { _$hash = $jc(_$hash, visibility.hashCode); _$hash = $jc(_$hash, assignable.hashCode); _$hash = $jc(_$hash, conversation.hashCode); + _$hash = $jc(_$hash, server.hashCode); _$hash = $jc(_$hash, etag.hashCode); _$hash = $jc(_$hash, width.hashCode); _$hash = $jc(_$hash, height.hashCode); @@ -19831,7 +19851,6 @@ class _$RichObjectParameter extends RichObjectParameter { ..add('type', type) ..add('id', id) ..add('name', name) - ..add('server', server) ..add('link', link) ..add('callType', callType) ..add('iconUrl', iconUrl) @@ -19851,6 +19870,7 @@ class _$RichObjectParameter extends RichObjectParameter { ..add('visibility', visibility) ..add('assignable', assignable) ..add('conversation', conversation) + ..add('server', server) ..add('etag', etag) ..add('width', width) ..add('height', height)) @@ -19862,9 +19882,9 @@ class RichObjectParameterBuilder implements Builder, $RichObjectParameterInterfaceBuilder { _$RichObjectParameter? _$v; - String? _type; - String? get type => _$this._type; - set type(covariant String? type) => _$this._type = type; + RichObjectParameter_Type? _type; + RichObjectParameter_Type? get type => _$this._type; + set type(covariant RichObjectParameter_Type? type) => _$this._type = type; String? _id; String? get id => _$this._id; @@ -19874,17 +19894,13 @@ class RichObjectParameterBuilder String? get name => _$this._name; set name(covariant String? name) => _$this._name = name; - String? _server; - String? get server => _$this._server; - set server(covariant String? server) => _$this._server = server; - String? _link; String? get link => _$this._link; set link(covariant String? link) => _$this._link = link; - RichObjectParameter_CallType? _callType; - RichObjectParameter_CallType? get callType => _$this._callType; - set callType(covariant RichObjectParameter_CallType? callType) => _$this._callType = callType; + String? _callType; + String? get callType => _$this._callType; + set callType(covariant String? callType) => _$this._callType = callType; String? _iconUrl; String? get iconUrl => _$this._iconUrl; @@ -19914,10 +19930,9 @@ class RichObjectParameterBuilder String? get mimetype => _$this._mimetype; set mimetype(covariant String? mimetype) => _$this._mimetype = mimetype; - RichObjectParameter_PreviewAvailable? _previewAvailable; - RichObjectParameter_PreviewAvailable? get previewAvailable => _$this._previewAvailable; - set previewAvailable(covariant RichObjectParameter_PreviewAvailable? previewAvailable) => - _$this._previewAvailable = previewAvailable; + String? _previewAvailable; + String? get previewAvailable => _$this._previewAvailable; + set previewAvailable(covariant String? previewAvailable) => _$this._previewAvailable = previewAvailable; String? _mtime; String? get mtime => _$this._mtime; @@ -19943,18 +19958,22 @@ class RichObjectParameterBuilder String? get website => _$this._website; set website(covariant String? website) => _$this._website = website; - RichObjectParameter_Visibility? _visibility; - RichObjectParameter_Visibility? get visibility => _$this._visibility; - set visibility(covariant RichObjectParameter_Visibility? visibility) => _$this._visibility = visibility; + String? _visibility; + String? get visibility => _$this._visibility; + set visibility(covariant String? visibility) => _$this._visibility = visibility; - RichObjectParameter_Assignable? _assignable; - RichObjectParameter_Assignable? get assignable => _$this._assignable; - set assignable(covariant RichObjectParameter_Assignable? assignable) => _$this._assignable = assignable; + String? _assignable; + String? get assignable => _$this._assignable; + set assignable(covariant String? assignable) => _$this._assignable = assignable; String? _conversation; String? get conversation => _$this._conversation; set conversation(covariant String? conversation) => _$this._conversation = conversation; + String? _server; + String? get server => _$this._server; + set server(covariant String? server) => _$this._server = server; + String? _etag; String? get etag => _$this._etag; set etag(covariant String? etag) => _$this._etag = etag; @@ -19977,7 +19996,6 @@ class RichObjectParameterBuilder _type = $v.type; _id = $v.id; _name = $v.name; - _server = $v.server; _link = $v.link; _callType = $v.callType; _iconUrl = $v.iconUrl; @@ -19997,6 +20015,7 @@ class RichObjectParameterBuilder _visibility = $v.visibility; _assignable = $v.assignable; _conversation = $v.conversation; + _server = $v.server; _etag = $v.etag; _width = $v.width; _height = $v.height; @@ -20026,7 +20045,6 @@ class RichObjectParameterBuilder type: BuiltValueNullFieldError.checkNotNull(type, r'RichObjectParameter', 'type'), id: BuiltValueNullFieldError.checkNotNull(id, r'RichObjectParameter', 'id'), name: BuiltValueNullFieldError.checkNotNull(name, r'RichObjectParameter', 'name'), - server: server, link: link, callType: callType, iconUrl: iconUrl, @@ -20046,6 +20064,7 @@ class RichObjectParameterBuilder visibility: visibility, assignable: assignable, conversation: conversation, + server: server, etag: etag, width: width, height: height); diff --git a/packages/nextcloud/lib/src/api/spreed.openapi.json b/packages/nextcloud/lib/src/api/spreed.openapi.json index f65d4f92e80..406abcbd8dd 100644 --- a/packages/nextcloud/lib/src/api/spreed.openapi.json +++ b/packages/nextcloud/lib/src/api/spreed.openapi.json @@ -895,7 +895,33 @@ ], "properties": { "type": { - "type": "string" + "type": "string", + "enum": [ + "addressbook", + "addressbook-contact", + "announcement", + "app", + "calendar", + "calendar-event", + "call", + "circle", + "deck-board", + "deck-card", + "email", + "file", + "forms-form", + "guest", + "highlight", + "geo-location", + "open-graph", + "pending-federated-share", + "systemtag", + "talk-attachment", + "talk-poll", + "user", + "user-group", + "group" + ] }, "id": { "type": "string" @@ -903,19 +929,11 @@ "name": { "type": "string" }, - "server": { - "type": "string" - }, "link": { "type": "string" }, "call-type": { - "type": "string", - "enum": [ - "one2one", - "group", - "public" - ] + "type": "string" }, "icon-url": { "type": "string" @@ -946,11 +964,7 @@ "type": "string" }, "preview-available": { - "type": "string", - "enum": [ - "yes", - "no" - ] + "type": "string" }, "mtime": { "type": "string" @@ -971,22 +985,17 @@ "type": "string" }, "visibility": { - "type": "string", - "enum": [ - "0", - "1" - ] + "type": "string" }, "assignable": { - "type": "string", - "enum": [ - "0", - "1" - ] + "type": "string" }, "conversation": { "type": "string" }, + "server": { + "type": "string" + }, "etag": { "type": "string" }, diff --git a/packages/nextcloud/lib/src/patches/spreed/1-message-parameters.json b/packages/nextcloud/lib/src/patches/spreed/1-message-parameters.json deleted file mode 100644 index f2eefe064f8..00000000000 --- a/packages/nextcloud/lib/src/patches/spreed/1-message-parameters.json +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "op": "replace", - "path": "/components/schemas/RichObjectParameter/properties/size", - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ] - } - }, - { - "op": "add", - "path": "/components/schemas/RichObjectParameter/properties/etag", - "value": { - "type": "string" - } - }, - { - "op": "add", - "path": "/components/schemas/RichObjectParameter/properties/width", - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ] - } - }, - { - "op": "add", - "path": "/components/schemas/RichObjectParameter/properties/height", - "value": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ] - } - } -] diff --git a/packages/nextcloud/lib/src/patches/spreed/1-rich-objects.json b/packages/nextcloud/lib/src/patches/spreed/1-rich-objects.json new file mode 100644 index 00000000000..3ae329da7d9 --- /dev/null +++ b/packages/nextcloud/lib/src/patches/spreed/1-rich-objects.json @@ -0,0 +1,127 @@ +[ + { + "op": "replace", + "path": "/components/schemas/BaseMessage/properties/messageParameters/additionalProperties", + "value": { + "$ref": "#/components/schemas/RichObjectParameter" + } + }, + { + "op": "add", + "path": "/components/schemas/RichObjectParameter", + "value": { + "type": "object", + "required": [ + "type", + "id", + "name" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "addressbook", + "addressbook-contact", + "announcement", + "app", + "calendar", + "calendar-event", + "call", + "circle", + "deck-board", + "deck-card", + "email", + "file", + "forms-form", + "guest", + "highlight", + "geo-location", + "open-graph", + "pending-federated-share", + "systemtag", + "talk-attachment", + "talk-poll", + "user", + "user-group", + "group" + ] + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "link": { + "type": "string" + }, + "call-type": { + "type": "string" + }, + "icon-url": { + "type": "string" + }, + "message-id": { + "type": "string" + }, + "boardname": { + "type": "string" + }, + "stackname": { + "type": "string" + }, + "size": { + "type": "string" + }, + "path": { + "type": "string" + }, + "mimetype": { + "type": "string" + }, + "preview-available": { + "type": "string" + }, + "mtime": { + "type": "string" + }, + "latitude": { + "type": "string" + }, + "longitude": { + "type": "string" + }, + "description": { + "type": "string" + }, + "thumb": { + "type": "string" + }, + "website": { + "type": "string" + }, + "visibility": { + "type": "string" + }, + "assignable": { + "type": "string" + }, + "conversation": { + "type": "string" + }, + "server": { + "type": "string" + }, + "etag": { + "type": "string" + }, + "width": { + "type": "string" + }, + "height": { + "type": "string" + } + } + } + } +] \ No newline at end of file diff --git a/packages/nextcloud/lib/src/patches/spreed/2-compatibility-18.json b/packages/nextcloud/lib/src/patches/spreed/2-compatibility-18.json index 92c81dcebec..e2956d1aedc 100644 --- a/packages/nextcloud/lib/src/patches/spreed/2-compatibility-18.json +++ b/packages/nextcloud/lib/src/patches/spreed/2-compatibility-18.json @@ -10,5 +10,47 @@ "previews", "signaling" ] + }, + { + "op": "replace", + "path": "/components/schemas/RichObjectParameter/properties/size", + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + } + }, + { + "op": "replace", + "path": "/components/schemas/RichObjectParameter/properties/width", + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + } + }, + { + "op": "replace", + "path": "/components/schemas/RichObjectParameter/properties/height", + "value": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + } } ] diff --git a/tool/generate-rich-objects-patch.php b/tool/generate-rich-objects-patch.php new file mode 100755 index 00000000000..87b742ca625 --- /dev/null +++ b/tool/generate-rich-objects-patch.php @@ -0,0 +1,117 @@ +#!/usr/bin/env php +definitions; + +/* +TODO: Use this more complex patch once discriminator support is back. + +$schemas = []; +$discriminatorSchema = [ + 'oneOf' => [], + 'discriminator' => [ + 'propertyName' => 'type', + 'mapping' => [], + ], +]; + +foreach ($definitions as $type => $object) { + $schema = [ + 'type' => 'object', + ]; + + $required = ['type']; + $properties = [ + 'type' => [ + 'type' => 'string', + ], + ]; + + foreach ($object['parameters'] as $name => $parameter) { + if ($parameter['required'] === true) { + $required[] = $name; + } + + $properties[$name] = [ + 'type' => 'string', + 'description' => $parameter['description'], + 'example' => $parameter['example'], + ]; + } + + $schema['required'] = $required; + $schema['properties'] = $properties; + + $schemaName = 'RichObjectParameter' . ucfirst(str_replace('-', '', ucwords($type, '-'))); + $schemas[$schemaName] = $schema; + + $discriminatorSchema['oneOf'][] = [ + '$ref' => '#/components/schemas/' . $schemaName, + ]; + $discriminatorSchema['discriminator']['mapping'][$type] = '#/components/schemas/' . $schemaName; +} + +$schemas['RichObjectParameter'] = $discriminatorSchema; + +$patch = [ + [ + 'op' => 'replace', + 'path' => '/components/schemas/ChatMessage/properties/messageParameters/additionalProperties', + 'value' => [ + '$ref' => '#/components/schemas/RichObjectParameter', + ], + ] +]; +foreach ($schemas as $name => $schema) { + $patch[] = [ + 'op' => 'add', + 'path' => '/components/schemas/' . $name, + 'value' => $schema, + ]; +} +*/ + +$properties = [ + 'type' => [ + 'type' => 'string', + 'enum' => array_keys($definitions), + ], + 'id' => ['type' => 'string'], + 'name' => ['type' => 'string'], +]; + +foreach ($definitions as $type => $object) { + foreach ($object['parameters'] as $name => $parameter) { + $properties[$name] ??= ['type' => 'string']; + } +} + +// TODO: Add these to the definitions +$properties['type']['enum'][] = 'group'; +$properties['etag'] = ['type' => 'string']; +$properties['width'] = ['type' => 'string']; +$properties['height'] = ['type' => 'string']; + +$patch = [ + [ + 'op' => 'replace', + 'path' => '/components/schemas/BaseMessage/properties/messageParameters/additionalProperties', + 'value' => [ + '$ref' => '#/components/schemas/RichObjectParameter', + ], + ], + [ + 'op' => 'add', + 'path' => '/components/schemas/RichObjectParameter', + 'value' => [ + 'type' => 'object', + 'required' => ['type', 'id', 'name'], + 'properties' => $properties, + ], + ], +]; + +file_put_contents('packages/nextcloud/lib/src/patches/spreed/1-rich-objects.json', json_encode($patch, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); diff --git a/tool/generate-specs.sh b/tool/generate-specs.sh index cea9aec1a1c..3914b79dde6 100755 --- a/tool/generate-specs.sh +++ b/tool/generate-specs.sh @@ -51,6 +51,8 @@ function generate_spec() { generate_spec "." "drop_account" ) +./tool/generate-rich-objects-patch.php + for spec in /tmp/nextcloud-neon/*.openapi.json; do name="$(basename "$spec" | cut -d "." -f 1)" if [[ "$name" == "core" ]]; then