Skip to content
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

Update to v7.0.0 #30

Merged
merged 18 commits into from
Jan 1, 2024
Merged

Update to v7.0.0 #30

merged 18 commits into from
Jan 1, 2024

Conversation

niklasweimann
Copy link
Member

No description provided.

/// <summary>
/// Point in time (Unix timestamp) when the chat was boosted
/// </summary>
public int AddDate { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to change all date types (int) to datetime? Because we can use the UnixDateTimeConverter?

@AleksandrFurmenkovOfficial

Thank you for your library. You might already know this, but there is also a need to implement a MessageOriginConverter like

internal class MessageOriginConverter : JsonConverter<MessageOrigin> // MessageOrigin should not be abstract 
{
    public override bool CanWrite => false;

    public override void WriteJson(JsonWriter writer, MessageOrigin value, JsonSerializer serializer)
    {
        throw new NotImplementedException("Unnecessary because CanWrite is false. The method should never be called.");
    }

    public override MessageOrigin ReadJson(
        JsonReader reader,
        Type objectType,
        MessageOrigin existingValue,
        bool hasExistingValue,
        JsonSerializer serializer)
    {
        var jsonObject = JObject.Load(reader);

        MessageOrigin messageOrigin = jsonObject["type"]
                                          ?.ToObject<RxTelegram.Bot.Interface.BaseTypes.Enums.MessageOrigin>() switch
                                      {
                                          RxTelegram.Bot.Interface.BaseTypes.Enums.MessageOrigin.Channel => new MessageOriginChannel(),
                                          RxTelegram.Bot.Interface.BaseTypes.Enums.MessageOrigin.Chat => new MessageOriginChat(),
                                          RxTelegram.Bot.Interface.BaseTypes.Enums.MessageOrigin.Hidden_User =>
                                              new MessageOriginHiddenUser(),
                                          RxTelegram.Bot.Interface.BaseTypes.Enums.MessageOrigin.User => new MessageOriginUser(),
                                          _ => throw new JsonSerializationException("Unknown type of MessageOrigin")
                                      };

        serializer.Populate(jsonObject.CreateReader(), messageOrigin);
        return messageOrigin;
    }
}

there is need proper mapping of the hidden_user type to the HiddenUser enum

Copy link

sonarqubecloud bot commented Jan 1, 2024

@niklasweimann niklasweimann merged commit b8912d4 into master Jan 1, 2024
5 checks passed
@niklasweimann niklasweimann deleted the v7.0.0 branch January 1, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants