PSSlack icon indicating copy to clipboard operation
PSSlack copied to clipboard

support tor thread_ts in send-slackfile and send-slackmessage

Open atartareanu opened this issue 5 years ago • 3 comments

send-slackfile and send-slackmessage should support threads

send-slackfile should be modified as follows:

...

    [parameter(ParameterSetName = 'Content')]
    [string]$FileType,

    [string[]]$Channel,
    [string]$thread_ts,
    [string]$FileName,
    [String]$Title,
    [String]$Comment,

... process { if ($Content) { $body = @{} switch ($psboundparameters.keys) { 'Content' {$body.content = $content} 'Channel' {$body.channels = $Channel -join ", " } 'thread_ts' {$body.thread_ts = $thread_ts} 'FileName' {$body.filename = $FileName} 'Title' {$body.Title = $Title} 'Comment' {$body.initial_comment = $Comment} 'FileType' {$body.filetype = $FileType} } ... switch ($psboundparameters.keys) { 'Channel' {$bodyLines += ("--$boundary$LF" + "Content-Disposition: form-data; name="channels"$LF" + "Content-Type: multipart/form-data$LF$LF" + ($Channel -join ", ") + $LF)}

            'thread_ts'    {$bodyLines +=
                            ("--$boundary$LF" +
                            "Content-Disposition: form-data; name=`"thread_ts`"$LF" +
                            "Content-Type: multipart/form-data$LF$LF" +
                            "$thread_ts$LF")}
            
            'FileName'    {$bodyLines +=
                            ("--$boundary$LF" +
                            "Content-Disposition: form-data; name=`"filename`"$LF" +
                            "Content-Type: multipart/form-data$LF$LF" +
                            "$FileName$LF")}

send-slackmessage ... $Username,

    [parameter(ParameterSetName = 'Param',
               ValueFromPipelineByPropertyName = $True)]
    $thread_ts,

    [parameter(ParameterSetName = 'Param',
               ValueFromPipelineByPropertyName = $True)]
    $IconUrl,

    [parameter(ParameterSetName = 'Param',
               ValueFromPipelineByPropertyName = $True)]
    $IconEmoji,

... if($PSCmdlet.ParameterSetName -eq 'Param') { $body = @{ }

        switch ($psboundparameters.keys)
        {
            'channel'     {$body.channel = $channel }
            'text'        {$body.text     = $text}
            'username'    {$body.username = $username}
            'thread_ts'   {$body.thread_ts = $thread_ts}
            'asuser'      {$body.as_user = $AsUser}
            'iconurl'     {$body.icon_url = $iconurl}
            'iconemoji'   {$body.icon_emoji   = $iconemoji}
            'linknames'   {$body.link_names = 1}
            'parse'       {$body.parse = $Parse}
            'UnfurlLinks' {$body.unfurl_links = $UnfurlLinks}
            'UnfurlMedia' {$body.unfurl_media = $UnfurlMedia}
            'attachments' {$body.attachments = $Attachments}
        }
        $Messages += $Body

....

atartareanu avatar Dec 06 '19 14:12 atartareanu

@atartareanu I was looking for this as well. Would you be able to submit a PR request since you have the code already figured out? CC @RamblingCookieMonster

rvigliotti-sf avatar Aug 26 '20 16:08 rvigliotti-sf

As of 2/21 it looks like the thread_ts has been removed from channels.replies, but has been replaced in the conversations.replies with just ts.

joshcorr avatar Jun 05 '21 20:06 joshcorr

@rvigliotti-sf and @atartareanu this should know be in version 1.0.6 of the module.

joshcorr avatar Jul 01 '21 23:07 joshcorr