Skip to content

Commit

Permalink
release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OnestarLee committed Nov 29, 2024
1 parent 9da92c1 commit 8df89a2
Show file tree
Hide file tree
Showing 51 changed files with 479 additions and 14 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# Change Log

## 4.0.1 (Nov 4, 2024)
## 4.1.0 (Nov 29, 2024)
### Features
- Added `SetPushTriggerOption` to `SendbirdChatClient`
- Added `GetPushTriggerOption` to `SendbirdChatClient`
- Added `SetMyPushTriggerOption` to `SbGroupChannel`
- Added `GetMyPushTriggerOption` to `SbGroupChannel`
- Added `SbPushTriggerOption`
### Bug Fixes
- Fixed an issue with `SendbirdChat.BlockUser` where 'User not found error' occurs due to URL encoding

## 4.0.1 (Nov 4, 2024)
### Bug Fixes
- Fixed an issue where build failed on the Windows platform

## 4.0.0 (Sep 25, 2024)
Expand All @@ -19,7 +29,7 @@
- Added support for .NET 4.x

## 4.0.0-beta.1 (Sep 15, 2023)
### Improvements
### Bug Fixes
- Fixed the bug regarding the URL encoding

## 4.0.0-beta (Aug 25, 2023)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright (c) 2024 Sendbird, Inc.
//

namespace Sendbird.Chat
{
public partial class SbGroupChannel
{
private void GetMyPushTriggerOptionInternal(SbGroupChannelGetMyPushTriggerOptionHandler inCompletionHandler)
{
if (inCompletionHandler == null)
return;

void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled)
{
if (inResponse is GetMyPushTriggerOptionApiCommand.Response response)
{
inCompletionHandler.Invoke(response.GroupChannelPushTriggerOption, inError);
return;
}

inCompletionHandler.Invoke(inMyPushTriggerOption: null, inError);
}

GetMyPushTriggerOptionApiCommand.Request apiCommand = new GetMyPushTriggerOptionApiCommand.Request(
chatMainContextRef.CurrentUserId, Url, OnCompletionHandler);

chatMainContextRef.CommandRouter.RequestApiCommand(apiCommand);
}

private void SetMyPushTriggerOptionInternal(SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, SbErrorHandler inCompletionHandler)
{
if (inCompletionHandler == null)
return;

void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled)
{
if (inResponse is SetMyPushTriggerOptionApiCommand.Response response)
{
_myPushTriggerOption = response.GroupChannelPushTriggerOption;
}

inCompletionHandler.Invoke(inError);
}

SetMyPushTriggerOptionApiCommand.Request apiCommand = new SetMyPushTriggerOptionApiCommand.Request(
chatMainContextRef.CurrentUserId, Url, inGroupChannelPushTriggerOption, OnCompletionHandler);

chatMainContextRef.CommandRouter.RequestApiCommand(apiCommand);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright (c) 2023 Sendbird, Inc.
//

using System;

namespace Sendbird.Chat
{
internal static class SbPushTriggerOptionExtension
{
private static int _enumCount = 0;

internal static SbPushTriggerOption? JsonNameToType(string inJsonName)
{
if (string.IsNullOrEmpty(inJsonName) == false)
{
if (_enumCount <= 0)
_enumCount = Enum.GetValues(typeof(SbPushTriggerOption)).Length;

for (SbPushTriggerOption enumType = 0; enumType < (SbPushTriggerOption)_enumCount; enumType++)
{
if (enumType.ToJsonName().Equals(inJsonName, StringComparison.OrdinalIgnoreCase))
return enumType;
}

Logger.Warning(Logger.CategoryType.Command, $"SbPushTriggerOption::ToJsonName Invalid type name:{inJsonName}");
}

return null;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,43 @@ internal void GetDoNotDisturb(SbDoNotDisturbHandler inCompletionHandler)
{
ChatMainContext.PushManager.GetDoNotDisturb(inCompletionHandler);
}

internal void GetPushTriggerOption(SbPushTriggerOptionHandler inCompletionHandler)
{
if (inCompletionHandler == null)
return;

void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled)
{
if (inResponse is GetPushTriggerOptionApiCommand.Response response)
{
inCompletionHandler.Invoke(response.GroupChannelPushTriggerOptionNullable, inError);
return;
}

inCompletionHandler.Invoke(inPushTriggerOption: null, inError);
}

GetPushTriggerOptionApiCommand.Request apiCommand = new GetPushTriggerOptionApiCommand.Request(
ChatMainContext.CurrentUserId, OnCompletionHandler);

ChatMainContext.CommandRouter.RequestApiCommand(apiCommand);
}

internal void SetPushTriggerOption(SbPushTriggerOption inPushTriggerOption, SbErrorHandler inCompletionHandler)
{
if (inCompletionHandler == null)
return;

void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled)
{
inCompletionHandler.Invoke(inError);
}

SetPushTriggerOptionApiCommand.Request apiCommand = new SetPushTriggerOptionApiCommand.Request(
ChatMainContext.CurrentUserId, inPushTriggerOption, OnCompletionHandler);

ChatMainContext.CommandRouter.RequestApiCommand(apiCommand);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Copyright (c) 2022 Sendbird, Inc.
//

using System;
using System.Net;
using Newtonsoft.Json;

namespace Sendbird.Chat
{
internal sealed class GetMyPushTriggerOptionApiCommand
{
internal sealed class Request : ApiCommandAbstract.GetRequest
{
internal Request(string inUserId, string inChannelUrl, ResultHandler inResultHandler)
{
string encodedUserId = WebUtility.UrlEncode(inUserId);
string encodedChannelUrl = WebUtility.UrlEncode(inChannelUrl);
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference/{encodedChannelUrl}";
ResponseType = typeof(Response);
resultHandler = inResultHandler;
}
}

[Serializable]
internal sealed class Response : ApiCommandAbstract.Response
{
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption;

internal SbGroupChannelPushTriggerOption? GroupChannelPushTriggerOption { get; private set; } = null;

internal override void OnResponseAfterDeserialize(string inJsonString)
{
if (string.IsNullOrEmpty(pushTriggerOption) == false)
{
GroupChannelPushTriggerOption = SbGroupChannelPushTriggerOptionExtension.JsonNameToType(pushTriggerOption);
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Copyright (c) 2022 Sendbird, Inc.
//

using System;
using System.Net;
using Newtonsoft.Json;

namespace Sendbird.Chat
{
internal sealed class SetMyPushTriggerOptionApiCommand
{
internal sealed class Request : ApiCommandAbstract.PutRequest
{
[Serializable]
private struct Payload
{
#pragma warning disable CS0649
[JsonProperty("push_trigger_option")] internal string pushTriggerOption;
#pragma warning restore CS0649
}

internal Request(string inUserId, string inChannelUrl, SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, ResultHandler inResultHandler)
{
string encodedUserId = WebUtility.UrlEncode(inUserId);
string encodedChannelUrl = WebUtility.UrlEncode(inChannelUrl);
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference/{encodedChannelUrl}";
ResponseType = typeof(Response);
resultHandler = inResultHandler;

Payload tempPayload = new Payload
{
pushTriggerOption = inGroupChannelPushTriggerOption.ToJsonName()
};

ContentBody = NewtonsoftJsonExtension.SerializeObjectIgnoreException(tempPayload);
}
}

[Serializable]
internal sealed class Response : ApiCommandAbstract.Response
{
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption;

internal SbGroupChannelPushTriggerOption GroupChannelPushTriggerOption { get; private set; }

internal override void OnResponseAfterDeserialize(string inJsonString)
{
if (string.IsNullOrEmpty(pushTriggerOption) == false)
{
GroupChannelPushTriggerOption = SbGroupChannelPushTriggerOptionExtension.JsonNameToType(pushTriggerOption);
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright (c) 2022 Sendbird, Inc.
//

using System;
using System.Net;
using Newtonsoft.Json;

namespace Sendbird.Chat
{
internal sealed class GetPushTriggerOptionApiCommand
{
internal sealed class Request : ApiCommandAbstract.GetRequest
{
internal Request(string inUserId, ResultHandler inResultHandler)
{
string encodedUserId = WebUtility.UrlEncode(inUserId);
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference";
ResponseType = typeof(Response);
resultHandler = inResultHandler;
}
}

[Serializable]
internal sealed class Response : ApiCommandAbstract.Response
{
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption;

internal SbPushTriggerOption? GroupChannelPushTriggerOptionNullable { get; private set; } = null;

internal override void OnResponseAfterDeserialize(string inJsonString)
{
if (string.IsNullOrEmpty(pushTriggerOption) == false)
{
GroupChannelPushTriggerOptionNullable = SbPushTriggerOptionExtension.JsonNameToType(pushTriggerOption);
}
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Copyright (c) 2022 Sendbird, Inc.
//

using System;
using System.Net;
using Newtonsoft.Json;

namespace Sendbird.Chat
{
internal sealed class SetPushTriggerOptionApiCommand
{
internal sealed class Request : ApiCommandAbstract.PutRequest
{
[Serializable]
private struct Payload
{
#pragma warning disable CS0649
[JsonProperty("push_trigger_option")] internal string pushTriggerOption;
#pragma warning restore CS0649
}

internal Request(string inUserId, SbPushTriggerOption inPushTriggerOption, ResultHandler inResultHandler)
{
string encodedUserId = WebUtility.UrlEncode(inUserId);
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference";
ResponseType = typeof(Response);
resultHandler = inResultHandler;

Payload tempPayload = new Payload
{
pushTriggerOption = inPushTriggerOption.ToJsonName()
};

ContentBody = NewtonsoftJsonExtension.SerializeObjectIgnoreException(tempPayload);
}
}

[Serializable]
internal sealed class Response : ApiCommandAbstract.Response
{
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption;
}
}
}
Loading

0 comments on commit 8df89a2

Please sign in to comment.