summaryrefslogtreecommitdiff
path: root/internal/gtscontext
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-06-22 20:46:36 +0100
committerLibravatar GitHub <noreply@github.com>2023-06-22 20:46:36 +0100
commit9a22102fa8b1ce47571d5bba71e8f36895d21bf0 (patch)
tree3c2af6db0a3905d31243cd840d1dd50bea59dbb0 /internal/gtscontext
parent[docs] Clarify email requirement for OIDC (#1918) (diff)
downloadgotosocial-9a22102fa8b1ce47571d5bba71e8f36895d21bf0.tar.xz
[bugfix/chore] oauth entropy fix + media cleanup tasks rewrite (#1853)
Diffstat (limited to 'internal/gtscontext')
-rw-r--r--internal/gtscontext/context.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/gtscontext/context.go b/internal/gtscontext/context.go
index c8cd42208..46f2899fa 100644
--- a/internal/gtscontext/context.go
+++ b/internal/gtscontext/context.go
@@ -41,8 +41,23 @@ const (
httpSigVerifierKey
httpSigKey
httpSigPubKeyIDKey
+ dryRunKey
)
+// DryRun returns whether the "dryrun" context key has been set. This can be
+// used to indicate to functions, (that support it), that only a dry-run of
+// the operation should be performed. As opposed to making any permanent changes.
+func DryRun(ctx context.Context) bool {
+ _, ok := ctx.Value(dryRunKey).(struct{})
+ return ok
+}
+
+// SetDryRun sets the "dryrun" context flag and returns this wrapped context.
+// See DryRun() for further information on the "dryrun" context flag.
+func SetDryRun(ctx context.Context) context.Context {
+ return context.WithValue(ctx, dryRunKey, struct{}{})
+}
+
// RequestID returns the request ID associated with context. This value will usually
// be set by the request ID middleware handler, either pulling an existing supplied
// value from request headers, or generating a unique new entry. This is useful for