diff --git a/README.md b/README.md index 5935a01..612a8f3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ - Ntfy was made by [Philipp C. Heckel](https://github.com/binwiederhier). Consider leaving a star in [his project](https://github.com/binwiederhier/ntfy). As [Philipp C. Heckel](https://github.com/binwiederhier) stated, this service will stay free, so any kind of support to afford costs help with cloud hosting will be warmly received. You can also self-host ntfy server. Visit [docs.ntfy.sh](https://docs.ntfy.sh/) to get started with documentation. + Ntfy was made by [Philipp C. Heckel](https://github.com/binwiederhier). Consider leaving a star on [his project](https://github.com/binwiederhier/ntfy). As [Philipp C. Heckel](https://github.com/binwiederhier) stated, this service will stay free, so any kind of support to afford costs help with cloud hosting will be warmly received. You can also self-host ntfy server. Visit [docs.ntfy.sh](https://docs.ntfy.sh/) to get started with documentation. ## 🔔 Ntfy for Delphi diff --git a/src/Notify.Api.Indy.pas b/src/Notify.Api.Indy.pas index b5f70d4..593d80d 100644 --- a/src/Notify.Api.Indy.pas +++ b/src/Notify.Api.Indy.pas @@ -189,6 +189,15 @@ function TNotifyApiIndy.Config(const AValue: INotifyConfig): INotifyApi; begin Result := Self; FNotifyConfig := AValue; + + if AValue.ProxyServer <> '' then + begin + FIdHttp.ProxyParams.ProxyServer := AValue.ProxyServer; + FIdHttp.ProxyParams.ProxyUsername := AValue.ProxyUser; + FIdHttp.ProxyParams.ProxyPassword := AValue.ProxyPassword; + FIdHttp.ProxyParams.ProxyPort := AValue.ProxyPort; + end; + end; constructor TNotifyApiIndy.Create; @@ -256,7 +265,7 @@ function TNotifyApiIndy.Get: INotifyApi; FConnectionThread.Start; end; - {$IFDEF CONSOLE} + {$IFDEF CONSOLE OR CONSOLE_TESTRUNNER} FConnectionThread.WaitFor; {$ENDIF} diff --git a/src/Notify.Config.Contract.pas b/src/Notify.Config.Contract.pas index 2579ba6..cb650ad 100644 --- a/src/Notify.Config.Contract.pas +++ b/src/Notify.Config.Contract.pas @@ -24,6 +24,11 @@ interface function LogPath(const AValue: String): INotifyConfig; overload; function SubscriptionType: TNotifySubscriptionType; overload; function SubscriptionType(const AValue: TNotifySubscriptionType): INotifyConfig; overload; + function ProxyServer: string; overload; + function ProxyUser: string; overload; + function ProxyPassword: string; overload; + function ProxyPort: integer; overload; + function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyConfig; overload; end; implementation diff --git a/src/Notify.Config.pas b/src/Notify.Config.pas index 9117930..7fa9309 100644 --- a/src/Notify.Config.pas +++ b/src/Notify.Config.pas @@ -17,6 +17,8 @@ TNotifyConfig = class sealed(TInterfacedObject, INotifyConfig) FSaveLog: Boolean; FLogPath: String; FSubscriptionType: TNotifySubscriptionType; + FProxyServer, FProxyUser, FProxyPassword: string; + FProxyPort: integer; public class function New: INotifyConfig; private @@ -37,6 +39,11 @@ TNotifyConfig = class sealed(TInterfacedObject, INotifyConfig) function LogPath(const AValue: String): INotifyConfig; overload; function SubscriptionType: TNotifySubscriptionType; overload; function SubscriptionType(const AValue: TNotifySubscriptionType): INotifyConfig; overload; + function ProxyServer: string; overload; + function ProxyUser: string; overload; + function ProxyPassword: string; overload; + function ProxyPort: integer; overload; + function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyConfig; overload; end; implementation @@ -114,6 +121,34 @@ function TNotifyConfig.Password(const AValue: String): INotifyConfig; FPassword := AValue; end; +function TNotifyConfig.Proxy(const AProxyServer, AProxyUser, AProxyPassword: string; const aProxyPort: integer): INotifyConfig; +begin + FProxyServer := AProxyServer; + FProxyUser := AProxyUser; + FProxyPassword := AProxyPassword; + FProxyPort := AProxyPort; +end; + +function TNotifyConfig.ProxyPassword: string; +begin + Result := FProxyPassword; +end; + +function TNotifyConfig.ProxyPort: integer; +begin + Result := FProxyPort; +end; + +function TNotifyConfig.ProxyServer: string; +begin + Result := FProxyServer; +end; + +function TNotifyConfig.ProxyUser: string; +begin + Result := FProxyUser; +end; + function TNotifyConfig.SaveLog(const AValue: Boolean): INotifyConfig; begin Result := Self; diff --git a/src/Notify.Core.Contract.pas b/src/Notify.Core.Contract.pas index 935b3c3..0604dec 100644 --- a/src/Notify.Core.Contract.pas +++ b/src/Notify.Core.Contract.pas @@ -37,6 +37,7 @@ interface function Scheduled(const AValue: Boolean): INotifyCore; overload; function Response: TNotifyApiResponse; function Disconnect: INotifyCore; + function Proxy(const AProxyServer, AProxyUser, AProxyPassword: String; const AProxyPort: Integer): INotifyCore; overload; end; INotifyCoreFacade = interface diff --git a/src/Notify.Core.pas b/src/Notify.Core.pas index 4271c1d..75dadfa 100644 --- a/src/Notify.Core.pas +++ b/src/Notify.Core.pas @@ -54,6 +54,7 @@ TNotifyCore = class sealed(TInterfacedObject, INotifyCore) function UserName(const AValue: String): INotifyCore; function Password(const AValue: String): INotifyCore; function BaseURL(const AValue: String): INotifyCore; + function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyCore; function DisableFireBase(const AValue: Boolean): INotifyCore; function Notification(const ANotification: INotifyNotification): INotifyCore; overload; function Filter(const AFilterType: TNotifyFilter; const AValue: String): INotifyCore; @@ -375,6 +376,12 @@ function TNotifyCore.Poll(const AValue: Boolean): INotifyCore; FPoll := AValue; end; +function TNotifyCore.Proxy(const aProxyServer, aProxyUser, + aProxyPassword: string; const aProxyPort: integer): INotifyCore; +begin + FConfig.Proxy(aProxyServer, aProxyUser, aProxyPassword, aProxyPort); +end; + function TNotifyCore.Publish: INotifyCore; begin Result := Self;