-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support to post in thread * specify thread timestamp and reply broadcast flag as context value --------- Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package slogslack | ||
|
||
import "context" | ||
|
||
type threadTimestampCtxKey struct{} | ||
|
||
// reply in thread to posts with timestamps set this | ||
func WithThreadTimestamp(ctx context.Context, ts string) context.Context { | ||
return context.WithValue(ctx, threadTimestampCtxKey{}, ts) | ||
} | ||
|
||
func ContextThreadTimestamp(ctx context.Context) string { | ||
if v, ok := ctx.Value(threadTimestampCtxKey{}).(string); ok { | ||
return v | ||
} | ||
return "" | ||
} | ||
|
||
type replyBroadcastCtxKey struct{} | ||
|
||
// broadcast to channel when replies to thread if set | ||
func WithReplyBroadcast(ctx context.Context) context.Context { | ||
return context.WithValue(ctx, replyBroadcastCtxKey{}, true) | ||
} | ||
|
||
func ContextReplyBroadcast(ctx context.Context) bool { | ||
_, ok := ctx.Value(replyBroadcastCtxKey{}).(bool) | ||
return ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters