chore: git mv

This commit is contained in:
td 2024-03-22 21:24:21 +05:30
parent af5445aa79
commit b7befd781e
No known key found for this signature in database
GPG Key ID: 62A30523D4D6CE28
74 changed files with 0 additions and 3072 deletions

View File

@ -1,71 +0,0 @@
name: 🐛 Bug Report
description: Report a bug to the product team
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report! This will help us to improve the product :)
- type: checkboxes
attributes:
label: Checklist
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I could not find a solution in the documentation, the existing issues or discussions.
required: true
- label: I already asked for help in the chat
- type: dropdown
attributes:
label: In which Project did the bug appear?
multiple: true
options:
- Famedly App
- Pharmacy Portal
- Flutter Admin Interface
- Other
- type: input
attributes:
label: If you selected \"Other\" as Project, please enter in which project the bug occurred.
- type: dropdown
attributes:
label: On which platform did the bug appear?
multiple: true
options:
- Android
- iOS
- Chrome
- Safari
- Firefox
- Edge
validations:
required: true
- type: input
attributes:
label: Matrix API Version
description: Which version of the Matrix Api (this Repo) are you using?
- type: textarea
attributes:
label: Describe the problem caused by this bug
description: |
A clear and concise description of the problem you have and what the bug is.
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this step...
1. With this device...
1. Run '...'
1. See error...
validations:
required: false
- type: textarea
attributes:
label: Screenshots or Logs
description: If applicable, add screenshots or Logs to help explain your problem.
- type: textarea
attributes:
label: Security related
description: If there is something related to security, please add it here

View File

@ -1 +0,0 @@
blank_issues_enabled: false

View File

@ -1,32 +0,0 @@
name: 🥸 [Product only] Create epic
description: "Creates a new epic which is used to build the Famedly Roadmap"
labels: ["epic"]
body:
- type: markdown
attributes:
value: |
This should be filled out by product.
- type: textarea
id: summary
attributes:
label: summary
description: Please write a summary
validations:
required: true
- type: textarea
id: intended-outcome
attributes:
label: Intended Outcome
description: What is the outcome for the user?
validations:
required: true
- type: textarea
id: technical-solution
attributes:
label: How will it work?
description: Please write down, how it will work
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.

View File

@ -1,47 +0,0 @@
name: 🛠️ Feature
description: "Create an new issue for a new Feature in Famedly"
labels: ["feature"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request
- type: checkboxes
id: preflight
attributes:
label: Preflight Checklist
options:
- label:
I could not find a solution in the existing issues, docs, nor discussions
required: true
- type: textarea
id: problem
attributes:
label: Describe your problem
description: Please describe your problem this new feature is supposed to solve.
placeholder: Describe the problem you have
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe your ideal solution
description: Which solution do you propose?
placeholder: As a [type of user], I want [some goal] so that [some reason].
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: Which version of the Famedly are you using.
- type: textarea
id: security
attributes:
label: Security requirements
description: Plese add more information in terms of security requirements.
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.

View File

@ -1,47 +0,0 @@
name: 🛠️ Improvement
description: "Create an new issue for an improvment in Famedly"
labels: ["improvement"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this improvement request
- type: checkboxes
id: preflight
attributes:
label: Preflight Checklist
options:
- label:
I could not find a solution in the existing issues, docs, nor discussions
required: true
- type: textarea
id: problem
attributes:
label: Describe your problem
description: Please describe your problem this improvement is supposed to solve.
placeholder: Describe the problem you have
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe your ideal solution
description: Which solution do you propose?
placeholder: As a [type of user], I want [some goal] so that [some reason].
validations:
required: true
- type: input
id: version
attributes:
label: Version
description: Which version of the Famedly are you using.
- type: textarea
id: security
attributes:
label: Security requirements
description: Plese add more information in terms of security requirements.
- type: textarea
id: additional
attributes:
label: Additional Context
description: Please add any other infos that could be useful.

View File

@ -1,25 +0,0 @@
name: General CI
on:
push:
branches:
- main
pull_request:
merge_group:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
dart:
permissions:
contents: read
uses: famedly/frontend-ci-templates/.github/workflows/dart.yml@main
with:
env_file: ".github/workflows/versions.env"
general:
permissions:
contents: read
uses: famedly/frontend-ci-templates/.github/workflows/general.yml@main

View File

@ -1,18 +0,0 @@
name: Add issues to Product Management Project.
on:
issues:
types:
- opened
jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v0.5.0
with:
# You can target a repository in a different organization
# to the issue
project-url: https://github.com/orgs/famedly/projects/4
github-token: ${{ secrets.ADD_ISSUE_TO_PROJECT_PAT }}

View File

@ -1,13 +0,0 @@
name: Publish CI
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
publish:
permissions:
contents: read
id-token: write
uses: famedly/frontend-ci-templates/.github/workflows/publish-pub.yml@main

View File

@ -1,2 +0,0 @@
flutter_version=3.13.6
dart_version=3.1.3

80
.gitignore vendored
View File

@ -1,80 +0,0 @@
# Miscellaneous
*.class
*.log
*.pyc
*.sw*
.DS_Store
.atom/
.buildlog/
.history
.svn/
native/
test/.test_coverage.dart
coverage/
coverage_badge.svg
# codegen related
*.bak
*.bakmacoscompat
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# Visual Studio Code related
.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/
pubspec.lock
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

View File

@ -1,38 +0,0 @@
include:
project: "famedly/company/frontend/ci-templates"
file: "all.yml"
test:
stage: test
image: dart
script:
- dart pub get
- dart pub run test
dry-run:
stage: deploy
image: dart
script:
- rm -rf ./docs
- dart pub get
- dart pub publish --dry-run
pub-dev:
stage: deploy
image: dart
dependencies: [dry-run]
script:
- rm -rf ./docs
- |
if [ -z "${PUB_DEV_CREDENTIALS}" ]; then
echo "Missing PUB_DEV_CREDENTIALS environment variable"
exit 1
fi
mkdir -p ~/.config/dart/
cp "${PUB_DEV_CREDENTIALS}" ~/.config/dart/pub-credentials.json
- dart pub get
- dart pub publish --force
rules:
- if: $CI_COMMIT_TAG

View File

@ -1,242 +0,0 @@
## [1.7.3] - 9th Jan 2023
Mark package as discontinued.
## [1.7.2] - 4th Oct 2023
- chore: add general and publish ci (td)
- chore: Add adjusted issue templates from product-management (Malin Errenst)
- chore: make dependencies compatible with dart 3 (Nicolas Werner)
- chore: add github action (Niklas Zender)
## [1.7.1] - 22nd Jun 2023
- fix: Fixed fake_matrix_api.dart signedOneTimeKeys upload (Malin Errenst)
- fix: Fix type cast to fix test in matrix-fhir-dart-sdk (Malin Errenst)
## [1.7.0] - 12th Jun 2023
Breaking Change:
Refactoring from Map<String, dynamic> to Map<String, Object?> makes some
type casts neccessary
- chore: add qr releated eventTypes (td)
- refactor: Get rid of dynamic lists (Krille)
- chore: bump version (Malin Errenst)
- docs: Add regenerate code instructions to readme (Krille)
- chore: Remove tags for CI test stage (Malin Errenst)
- refactor: Changed Map<String, dynamic> to Map<String, Object?> (Malin Errenst)
- chore: generated folder from recent dart_openapi_codegen (Malin Errenst)
- chore: sort imports (Nicolas Werner)
- ci: Use the ci template (Nicolas Werner)
## [1.6.1] - 17th Apr 2023
Fixes a small issue in the last release, where some enhanced enums were not
updated and as such missing a few members.
- fix: Update the generated enum files
## [1.6.0] - 17th Apr 2023
This release updates to version 1.6 of the Matrix specification. Users might
need to update their read receipt calls to the API changes.
- feat: Upgrade to spec 1.6
## [1.1.10] - 27th Jan 2023
- chore: Update enhanced_enum to 0.2.4
## [1.1.9] - 7th Nov 2022
- feat: Allow converting of stacktraces in logs
## [1.1.8] - 29th Aug 2022
- fix: Edge case where MatrixException.error differs from errcode
- chore: add pushrules to the event types
## [1.1.7] - 29th Aug 2022
- fix: Parsing of MatrixException parameters
## [1.1.6] - 26th Aug 2022
- fix: Fixed missing .pub-cache folder creation in .gitlab-ci.yml
## [1.1.5] - 25th Aug 2022
- fix: Fixed dysfunctional key-verification (Emoji+manual)
## [1.1.4] - 25th Aug 2022
- Revert "fix: Secret storage keys are used as account data but are not uri encoded"
- chore: disable dynamic calls (Nicolas Werner)
- chore: export filter map extension (Nicolas Werner)
- chore: strict casts (Nicolas Werner)
- chore: strict inference (Nicolas Werner)
- chore: strict raw types (Nicolas Werner)
- chore: upgrade from pedantic to lints (Nicolas Werner)
## [1.1.3] - 2nd Aug 2022
- fix: Secret storage keys are used as account data but are not uri encoded
- chore: export filter map extension
## [1.1.2] - 2nd Aug 2022
- feat: Add a flag to disable colors in logs
## 1.1.1
- fix: wrong type for children_state in spaces hierarchy API
- fix: Missing trailing slash on pushrules endpoint
- tests: added tests for spaces hierarchy
## 1.1.0
- fix: wrong types in spaces hierarchy API
- fix: Add missing versions to fake matrix api
- feat: Authenticate media downloads
## 1.0.0
This release should be compatible with version 1.2 of the Matrix specification.
- feat: Migrate to Matrix v1.2 spec
- feat: Add GroupCallPrefix/GroupCallMemberPrefix to EventTypes.
## 0.5.3
- chore: Add missing matrix error types as per spec
- feat: add additionalProperties in PusherData
- feat: deletePusher
## 0.5.2
- feat: Colored logs on native and web
- chore: Make some tryGet errors verbose and display line
## 0.5.1
- feat: Add constructors to SyncUpdate classes
## 0.5.0
- fix: threepidCreds should be threepid_creds and an object
## 0.4.4
- chore: workaround for invalid getTurnServer responses from synapse
## 0.4.3
- fix: Make type in AuthenticationData nullable
- refactor: remove uploadKeySignatures (use uploadCrossSigningSignatures)
## 0.4.2
- feat: Add more call event for improve voip.
## 0.4.1
- fix: change tryGet default loglevel to Optional
## 0.4.0
- refactor: Migrate to null safety
- refactor: Use openAPI code generation to create most of the methods
- refactor: remove timeouts in matrix_api_lite
## 0.3.5
- feat: Add image pack event content models
## 0.3.3
- fix: Log filter in wrong direction
## 0.3.2
- fix: Logs should only printed if loglevel is high enough
## 0.3.1
- change: Remove logger package
## 0.3.0
- feat: operation names from OpenAPI spec
## 0.2.6
- fix: Missing RoomCreationTypes
## 0.2.5
- fix: Request aliases
## 0.2.3
- feat: Add room and event types for spaces
## 0.2.2
- chore: upgrade logger to 1.0.0
- refactor: upgrade to http 0.13
## 0.2.1
- fix: Update dependency mime
## 0.2.0
- refactor: login method AuthenticationIdentifier
This is a breaking change for the login method to use the correct format.
It makes it possible to login with email or phone.
Also this does some housekeeping stuff while
upgrading to pedantic 1.11.0 which doesnt
allow curly braces in Strings where not needed
anymore.
## 0.1.9
- feat: Add support for fallback keys
## 0.1.8
- fix: Wrong parameters use
## 0.1.7
- change: Less noisy one-line logs
## 0.1.6
- fix: well-known in fake_matrix_api
## 0.1.5
- Add m.dummy event
- fix: Deep-copy arrays correctly
## 0.1.4
- Fix creating shallow copies all the time
## 0.1.3
- Set Content-Length on upload
## 0.1.2
- Add more encryption and decryption content parsing
## 0.1.1
- Add RoomEncryptedContent and RoomEncryptionContent
## 0.1.0
- Initial version

View File

@ -1,37 +0,0 @@
# Contributing code to Matrix API Lite
Everyone is welcome to contribute code to Matrix API Lite, provided that they are willing to license their contributions under the same license as the project itself.
Please follow these rules when contributing code to Matrix API Lite:
## Merge Requests:
- Never ever just push something directly to the main branch!
- Create a new branch or fork this project and send a Merge Request.
- Only Merge Requests with a working CI can be merged.
- Only Merge Requests with at least one code reviewer can be merged.
- Merge Requests may be refused if they don't follow the rules below.
- A new Merge Request SHOULD never decrease the test coverage.
## Branches
### Naming
Branches should get named by this pattern: `[Author]/[Description]`.
## Commit Messages
Please use [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0-beta.2/).
## File structure:
- Every file must be named by the class and must be capitalized in the beginning.
- Directories need to be lowercase.
## Code style:
Please use code formatting. You can use VSCode or Android Studio. On other editors you need to run:
```
flutter format lib/**/*/*.dart
```
## Code quality:
- Don't repeat yourself! Use local variables, functions, classes.
- Write tests for new classes, functions and widgets.
- Keep it simple stupid: https://en.wikipedia.org/wiki/KISS_principle
- Describe all of your classes, methods and attributes using **dartdoc** comments. Read this for more information: https://dart.dev/guides/language/effective-dart/documentation

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (C) 2021 Famedly GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,49 +0,0 @@
# Deprecation Notice:
This package will soon be merged with the [Matrix Dart SDK](https://pub.dev/packages/matrix) and from there be available as a library, not a stand alone package anymore. We hope that this will save us some overhead when maintaining the code. If you rely on this package as stand alone and importing the whole Matrix Dart SDK just to use this library is not an option for you, please open an issue here: https://github.com/famedly/dart_matrix_api_lite/issues
# Matrix API Lite
This package is a dead simple data model over the client-server specification of https://matrix.org and is mostly used as a base for a more complete Matrix SDK.
It doesn't contain any logic and just provides methods for all API endpoints and json parser for all objects. It is intended to be as close to the specificaton
as possible so we get a 1:1 relationship with the API. More complex logic like a sync loop or a data model for rooms should be implemented in a more complete
Matrix SDK.
## Usage
A simple usage example:
```dart
import 'package:matrix_api_lite/src/matrix_api.dart';
void main() async {
final api = MatrixApi(homeserver: Uri.parse('https://matrix.org'));
final capabilities = await api.requestServerCapabilities();
print(capabilities.toJson());
}
```
## Generated code
The files in `lib/src/generated` are generated by [dart_openapi_codegen](https://gitlab.com/famedly/company/frontend/dart_openapi_codegen/)
from [matrix-spec](https://github.com/matrix-org/matrix-spec/).
To regenerate the code, follow these steps:
1. Clone both repositories next to each other
1.1 `git clone git@github.com:famedly/dart_openapi_codegen.git`
1.2 `git clone git@github.com:famedly/dart_matrix_api_lite.git`
2. Execute the script in the dart_openapi_codegen directory:
```sh
cd dart_openapi_codegen
./scripts/matrix.sh ../dart_matrix_api_lite/lib/src/generated
cd ..
```
3. Run the build_runner in the matrix_api_lite directory:
```sh
cd dart_matrix_api_lite
dart pub get
dart run build_runner build
```
4. Check lints and tests and create a merge request

View File

@ -1,21 +0,0 @@
include: package:lints/recommended.yaml
linter:
rules:
camel_case_types: true
avoid_print: true
constant_identifier_names: false
prefer_final_locals: true
prefer_final_in_for_each: true
avoid_dynamic_calls: true
analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
todo: ignore
exclude:
- example/matrix_api_lite_example.dart
- lib/src/generated/**.dart

View File

@ -1,8 +0,0 @@
// @dart=2.9
import 'package:matrix_api_lite/src/matrix_api.dart';
void main() async {
final api = MatrixApi(homeserver: Uri.parse('https://matrix.org'));
final capabilities = await api.requestServerCapabilities();
print(capabilities.toJson());
}

View File

@ -1,24 +0,0 @@
name: matrix_api_lite
description: Dead simple data model for the matrix.org client-server API.
version: 1.7.3
homepage: https://famedly.com
repository: https://github.com/famedly/dart_matrix_api_lite
issues: https://github.com/famedly/dart_matrix_api_lite/issues
environment:
sdk: ">=2.17.0 <4.0.0"
dependencies:
enhanced_enum: ^0.2.4
http: ">=0.13.0 <2.0.0"
mime: ^1.0.0
dev_dependencies:
build_runner: ^2.1.8
enhanced_enum_generator: ^0.2.4
import_sorter: ^4.6.0
lints: ^2.0.0
test: ^1.14.4
# dependency_overrides: # uncomment for local development
# matrix:
# path: "../matrix-dart-sdk"

View File

@ -1,251 +0,0 @@
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import 'dart:convert';
import 'package:test/test.dart';
import 'package:matrix_api_lite/matrix_api_lite.dart';
void main() {
group('Event Content tests', () {
test('Room Encryption Content', () {
Map<String, Object?>? json = <String, Object?>{
'content': {
'algorithm': 'm.megolm.v1.aes-sha2',
'rotation_period_ms': 604800000,
'rotation_period_msgs': 100
},
'event_id': '\$143273582443PhrSn:example.org',
'origin_server_ts': 1432735824653,
'room_id': '!jEsUZKDJdhlrceRyVU:example.org',
'sender': '@example:example.org',
'state_key': '',
'type': 'm.room.encryption',
'unsigned': {'age': 1234}
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptionContent.toJson(),
json['content']);
});
test('Room Encrypted Content', () {
Map<String, Object?>? json = <String, Object?>{
'content': {
'algorithm': 'm.megolm.v1.aes-sha2',
'ciphertext': 'AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...',
'device_id': 'RJYKSTBOIE',
'sender_key': 'IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA',
'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ'
},
'event_id': '\$143273582443PhrSn:example.org',
'origin_server_ts': 1432735824653,
'room_id': '!jEsUZKDJdhlrceRyVU:example.org',
'sender': '@example:example.org',
'type': 'm.room.encrypted',
'unsigned': {'age': 1234}
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(),
json['content']);
json = <String, Object?>{
'content': {
'algorithm': 'm.olm.v1.curve25519-aes-sha2',
'ciphertext': {
'7qZcfnBmbEGzxxaWfBjElJuvn7BZx+lSz/SvFrDF/z8': {
'body': 'AwogGJJzMhf/S3GQFXAOrCZ3iKyGU5ZScVtjI0KypTYrW...',
'type': 0
}
},
'sender_key': 'Szl29ksW/L8yZGWAX+8dY1XyFi+i5wm+DRhTGkbMiwU'
},
'event_id': '\$143273582443PhrSn:example.org',
'origin_server_ts': 1432735824653,
'room_id': '!jEsUZKDJdhlrceRyVU:example.org',
'sender': '@example:example.org',
'type': 'm.room.encrypted',
'unsigned': {'age': 1234}
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(),
json['content']);
});
test('Room Key Content', () {
Map<String, Object?>? json = <String, Object?>{
'content': {
'algorithm': 'm.megolm.v1.aes-sha2',
'room_id': '!Cuyf34gef24t:localhost',
'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ',
'session_key': 'AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8LlfJL7qNBEY...'
},
'type': 'm.room_key'
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(BasicEvent.fromJson(json!).parsedRoomKeyContent.toJson(),
json['content']);
});
test('Room Key Request Content', () {
Map<String, Object?>? json = <String, Object?>{
'content': {
'action': 'request_cancellation',
'request_id': '1495474790150.19',
'requesting_device_id': 'RJYKSTBOIE'
},
'type': 'm.room_key_request'
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(),
json['content']);
json = <String, Object?>{
'content': {
'action': 'request',
'body': {
'algorithm': 'm.megolm.v1.aes-sha2',
'room_id': '!Cuyf34gef24t:localhost',
'sender_key': 'RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU',
'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ'
},
'request_id': '1495474790150.19',
'requesting_device_id': 'RJYKSTBOIE'
},
'type': 'm.room_key_request'
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(),
json['content']);
});
test('Forwarded Room Key Content', () {
Map<String, Object?>? json = <String, Object?>{
'content': {
'algorithm': 'm.megolm.v1.aes-sha2',
'forwarding_curve25519_key_chain': [
'hPQNcabIABgGnx3/ACv/jmMmiQHoeFfuLB17tzWp6Hw'
],
'room_id': '!Cuyf34gef24t:localhost',
'sender_claimed_ed25519_key':
'aj40p+aw64yPIdsxoog8jhPu9i7l7NcFRecuOQblE3Y',
'sender_key': 'RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU',
'session_id': 'X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ',
'session_key': 'AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8Llf...'
},
'type': 'm.forwarded_room_key'
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(BasicEvent.fromJson(json!).parsedForwardedRoomKeyContent.toJson(),
json['content']);
});
test('OLM Plaintext Payload', () {
Map<String, Object?>? json = <String, Object?>{
'type': '<type of the plaintext event>',
'content': <String, Object?>{
'msgtype': 'm.text',
'body': 'Hello world',
},
'sender': '<sender_user_id>',
'recipient': '<recipient_user_id>',
'recipient_keys': {'ed25519': '<our_ed25519_key>'},
'keys': {'ed25519': '<sender_ed25519_key>'}
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
expect(OlmPlaintextPayload.fromJson(json!).toJson(), json);
});
test('Image Pack Content', () {
// basic parse / unparse
var json = <String, Object?>{
'type': 'some type',
'content': {
'images': {
'emote': {
'url': 'mxc://example.org/beep',
'usage': ['emoticon'],
'org.custom': 'beep',
},
'sticker': {
'url': 'mxc://example.org/boop',
'usage': ['org.custom', 'sticker', 'org.other.custom'],
},
},
'pack': {
'display_name': 'Awesome Pack',
'org.custom': 'boop',
},
'org.custom': 'blah',
},
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
expect(BasicEvent.fromJson(json).parsedImagePackContent.toJson(),
json['content']);
// emoticons migration
json = <String, Object?>{
'type': 'some type',
'content': {
'emoticons': {
':emote:': {
'url': 'mxc://example.org/beep',
},
},
},
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
expect(
BasicEvent.fromJson(json)
.parsedImagePackContent
.images['emote']
?.toJson(),
{
'url': 'mxc://example.org/beep',
});
json = <String, Object?>{
'type': 'some type',
'content': {
'short': {
':emote:': 'mxc://example.org/beep',
},
},
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
expect(
BasicEvent.fromJson(json)
.parsedImagePackContent
.images['emote']
?.toJson(),
{
'url': 'mxc://example.org/beep',
});
// invalid url for image
json = <String, Object?>{
'type': 'some type',
'content': {
'images': {
'emote': <String, Object?>{},
},
},
};
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
expect(BasicEvent.fromJson(json).parsedImagePackContent.images['emote'],
null);
});
});
}

View File

@ -1,59 +0,0 @@
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import 'package:test/test.dart';
import 'package:matrix_api_lite/matrix_api_lite.dart';
void main() {
group('Map-copy-extension', () {
test('it should work', () {
final original = <String, Object?>{
'attr': 'fox',
'child': <String, Object?>{
'attr': 'bunny',
'list': [1, 2],
},
};
final copy = original.copy();
(original['child'] as Map<String, Object?>)['attr'] = 'raccoon';
expect((copy['child'] as Map<String, Object?>)['attr'], 'bunny');
((original['child'] as Map<String, Object?>)['list'] as List<int>).add(3);
expect((copy['child'] as Map<String, Object?>)['list'], [1, 2]);
});
test('should do arrays', () {
final original = <String, Object?>{
'arr': [
[1, 2],
{'beep': 'boop'},
],
};
final copy = original.copy();
((original['arr'] as List)[0] as List<int>).add(3);
expect((copy['arr'] as List)[0], [1, 2]);
((original['arr'] as List)[1] as Map<String, Object?>)['beep'] = 'blargh';
expect(
((copy['arr'] as List)[1] as Map<String, Object?>)['beep'], 'boop');
});
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +0,0 @@
/* MIT License
*
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import 'package:test/test.dart';
import 'package:matrix_api_lite/matrix_api_lite.dart';
void main() {
group('Try-get-map-extension', () {
Logs().level = Level.verbose;
test('it should work', () {
final data = <String, Object?>{
'str': 'foxies',
'int': 42,
'list': [2, 3, 4],
'map': <String, Object?>{
'beep': 'boop',
},
};
expect(data.tryGet<String>('str'), 'foxies');
expect(data.tryGet<int>('str'), null);
expect(data.tryGet<int>('int'), 42);
expect(data.tryGet<List<int>>('list'), [2, 3, 4]);
expect(data.tryGetMap<String, Object?>('map')?.tryGet<String>('beep'),
'boop');
expect(
data.tryGetMap<String, Object?>('map')?.tryGet<String>('meep'), null);
expect(
data.tryGetMap<String, Object?>('pam')?.tryGet<String>('beep'), null);
});
});
}