Skip to content

Commit 6cc4883

Browse files
authored
Merge pull request #293 from bakester14/wcb-issue-292
Don't post as_user unless specified.
2 parents bf04a45 + 258fd0c commit 6cc4883

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

SlackAPI/SlackClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ public void Update(
618618
bool linkNames = false,
619619
IBlock[] blocks = null,
620620
Attachment[] attachments = null,
621-
bool as_user = false)
621+
bool? as_user = null)
622622
{
623623
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
624624

@@ -648,9 +648,9 @@ public void Update(
648648
{
649649
NullValueHandling = NullValueHandling.Ignore
650650
})));
651-
652-
653-
parameters.Add(new Tuple<string, string>("as_user", as_user.ToString()));
651+
652+
if (as_user.HasValue)
653+
parameters.Add(new Tuple<string, string>("as_user", as_user.ToString()));
654654

655655
APIRequestWithToken(callback, parameters.ToArray());
656656
}

SlackAPI/SlackTaskClient.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ public Task<UpdateResponse> UpdateAsync(string ts,
607607
string parse = null,
608608
bool linkNames = false,
609609
Attachment[] attachments = null,
610-
bool as_user = false,
610+
bool? as_user = null,
611611
IBlock[] blocks = null)
612612
{
613613
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>();
@@ -628,7 +628,8 @@ public Task<UpdateResponse> UpdateAsync(string ts,
628628
if (attachments != null && attachments.Length > 0)
629629
parameters.Add(new Tuple<string, string>("attachments", JsonConvert.SerializeObject(attachments)));
630630

631-
parameters.Add(new Tuple<string, string>("as_user", as_user.ToString()));
631+
if (as_user.HasValue)
632+
parameters.Add(new Tuple<string, string>("as_user", as_user.ToString()));
632633

633634
if (blocks != null && blocks.Length > 0)
634635
parameters.Add(new Tuple<string, string>("blocks", JsonConvert.SerializeObject(blocks,
@@ -657,7 +658,7 @@ public Task<PostMessageResponse> PostMessageAsync(
657658
bool? unfurl_links = null,
658659
string icon_url = null,
659660
string icon_emoji = null,
660-
bool as_user = false,
661+
bool? as_user = null,
661662
string thread_ts = null)
662663
{
663664
List<Tuple<string,string>> parameters = new List<Tuple<string,string>>();
@@ -697,8 +698,8 @@ public Task<PostMessageResponse> PostMessageAsync(
697698
if (!string.IsNullOrEmpty(icon_emoji))
698699
parameters.Add(new Tuple<string, string>("icon_emoji", icon_emoji));
699700

700-
if (as_user)
701-
parameters.Add(new Tuple<string, string>("as_user", true.ToString()));
701+
if (as_user.HasValue)
702+
parameters.Add(new Tuple<string, string>("as_user", as_user.ToString()));
702703

703704
if (!string.IsNullOrEmpty(thread_ts))
704705
parameters.Add(new Tuple<string, string>("thread_ts", thread_ts));

0 commit comments

Comments
 (0)