Class NtfyPublisher
Zero framework dependencies — this class is plain-constructed by AlertEngine/
NtfyClient, not managed by any DI container. It never calls an SLF4J logger and never posts to a
Logback StatusManager; the caller owns all diagnostics and only consumes the returned
PublishResult.
Internal transport. This class is public only because AlertEngine,
NtfyClient and StartupSelfTest needed it before there was anywhere better to put
it — not because it was designed as an entry point. It is NOT covered by this library's
binary-compatibility guarantee, its shape is free to change within 2.x, and it is scheduled to
stop being public in 3.0. Publish through NtfyClient instead, which is the supported
surface for sending a notification of your own.
No SSRF guard is included here — that concern is out of scope for a plain HTTP publisher and
is the consumer's responsibility if the target URL is derived from untrusted input. The topic,
however, IS validated (ntfy's own [-_A-Za-z0-9]{1,64} rule): it is concatenated into the
request path, and a topic containing /, ?, #, or .. would
otherwise rewrite the request target (cross-topic publishing with the configured credential).
-
Constructor Summary
ConstructorsConstructorDescriptionNtfyPublisher(HttpClient httpClient) NtfyPublisher(HttpClient httpClient, Duration requestTimeout) -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.publish(String url, String topic, String title, AuthMode auth, String body, String priority, String tags) Deprecated.publish(String url, String topic, String title, AuthMode auth, String body, String priority, String tags, String click) Deprecated.publish(String url, String topic, String title, AuthMode auth, String body, String priority, String tags, String click, String actions) Deprecated.
-
Constructor Details
-
NtfyPublisher
-
NtfyPublisher
-
-
Method Details
-
publish
@Deprecated(since="2.1.0") public PublishResult publish(String url, String topic, String title, AuthMode auth, String body) Deprecated.Publishestitle/bodyto{url}/{topic}with noPriority/Tags/Clickheaders. Delegates topublish(String, String, String, AuthMode, String, String, String, String)withpriority/tags/clickallnull.- Returns:
- a
PublishResultdescribing the outcome; never throws
-
publish
@Deprecated(since="2.1.0") public PublishResult publish(String url, String topic, String title, AuthMode auth, String body, String priority, String tags) Deprecated.Priority/tags overload with noClickheader. Delegates topublish(String, String, String, AuthMode, String, String, String, String)withclicknull.- Returns:
- a
PublishResultdescribing the outcome; never throws
-
publish
@Deprecated(since="2.1.0") public PublishResult publish(String url, String topic, String title, AuthMode auth, String body, String priority, String tags, String click) Deprecated.Priority/tags/click overload with noActionsheader. Delegates topublish(String, String, String, AuthMode, String, String, String, String, String)withactionsnull.- Returns:
- a
PublishResultdescribing the outcome; never throws
-
publish
@Deprecated(since="2.1.0") public PublishResult publish(String url, String topic, String title, AuthMode auth, String body, String priority, String tags, String click, String actions) Deprecated.Publishestitle/bodyto{url}/{topic}, additionally forwardingpriority,tags,clickandactionsas ntfy'sPriority,Tags,ClickandActionsHTTP headers.clickis the URL ntfy opens when the notification is tapped;actionsis a pre-serialized ntfyActionsheader value (seeNtfyActionSerializer).A blank/null value for any of
priority/tags/click/actionssends no corresponding header. Values containing non-printable-ASCII characters are omitted rather than forwarded: the CRLF-injection guard must not depend solely on the JDK client's header validation, and a single invalid configured value must not abort every publish at the header-build boundary.The
Authorizationheader (if any) comes entirely from the suppliedAuthMode:auth.buildHeader()returns the header value to send, orOptional.empty()to send noAuthorizationheader at all (a valid anonymous publish).- Returns:
- a
PublishResultdescribing the outcome; never throws
-