-
Notifications
You must be signed in to change notification settings - Fork 15
[TeamsBotApps] Add all message activity handlers and schema #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next/core
Are you sure you want to change the base?
Conversation
This reverts commit 6f243f9.
rido-min
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking great !! I have some suggestions/comments that might be worth it to review in person
| /// <summary> | ||
| /// Represents a message reaction activity. | ||
| /// </summary> | ||
| public const string MessageReaction = "messageReaction"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to have these types in Core? I think those should be moved to TeamsSchema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I was just getting confused where to put it
| if (addText) | ||
| { | ||
| string? currentText = activity.Properties.TryGetValue("text", out object? value) ? value?.ToString() : null; | ||
| string? currentText = activity.Properties.TryGetValue("text", out var t) ? t?.ToString() : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we need the text maybe we could use MessageActivity.. I dont think mentions make sense in other activity types
| MessageActivity activity = new("Hello World"); | ||
| Assert.Equal(ActivityType.Message, activity.Type); | ||
| Assert.Equal(TeamsActivityType.Message, activity.Type); | ||
| Assert.Equal("Hello World", activity.Text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to check TextFormat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is for the constructor which doesn't set TextFormat, you think it should ? Other tests check it
| .Rebase(); | ||
| public static new TeamsActivity FromJsonString(string json) | ||
| { | ||
| using JsonDocument doc = JsonDocument.Parse(json); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a double deserialization, if we only need the type we could use a reader.
| /// </summary> | ||
| public static readonly string MessageReaction = "messageReaction"; | ||
|
|
||
| internal static readonly Dictionary<string, (Func<CoreActivity, TeamsActivity> FromActivity, Func<string, TeamsActivity> FromJson)> ActivityDeserializerMap = new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very interesting, let's chat about it
| public static new TeamsActivity FromJsonString(string json) => | ||
| FromJsonString(json, TeamsActivityJsonContext.Default.TeamsActivity) | ||
| .Rebase(); | ||
| public static new TeamsActivity FromJsonString(string json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we coud think of adding a generic here to return the concrete activities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added overload for that
| /// <returns>A MessageReactionActivity instance.</returns> | ||
| public static new MessageReactionActivity FromJsonString(string json) | ||
| { | ||
| MessageReactionActivity activity = JsonSerializer.Deserialize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use FromJson from the base?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, added generic overload/helper to base class and using that
No description provided.