mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Added possibility to change image uploader's form body with Enviroment Variables (#1709)
This commit is contained in:
parent
ccdbedb93c
commit
50d669a1af
|
@ -30,6 +30,10 @@ Notes:
|
||||||
- If you want to host the images yourself. You need [Nuuls' filehost software](https://github.com/nuuls/filehost)
|
- If you want to host the images yourself. You need [Nuuls' filehost software](https://github.com/nuuls/filehost)
|
||||||
- Other image hosting software is currently not supported.
|
- Other image hosting software is currently not supported.
|
||||||
|
|
||||||
|
### CHATTERINO2_IMAGE_UPLOADER_FORM_BODY
|
||||||
|
Used to change the name of an image form field in a request to the URL that Chatterino2 uses when trying to paste an image into chat. This can be used when your image uploading software accepts a different form field than default value.
|
||||||
|
Default value: `attachment`
|
||||||
|
|
||||||
### CHATTERINO2_TWITCH_SERVER_HOST
|
### CHATTERINO2_TWITCH_SERVER_HOST
|
||||||
String value used to change what Twitch chat server host to connect to.
|
String value used to change what Twitch chat server host to connect to.
|
||||||
Default value: `irc.chat.twitch.tv`
|
Default value: `irc.chat.twitch.tv`
|
||||||
|
|
|
@ -59,6 +59,8 @@ Env::Env()
|
||||||
"https://braize.pajlada.com/chatterino/twitchemotes/set/%1/"))
|
"https://braize.pajlada.com/chatterino/twitchemotes/set/%1/"))
|
||||||
, imageUploaderUrl(readStringEnv("CHATTERINO2_IMAGE_UPLOADER_URL",
|
, imageUploaderUrl(readStringEnv("CHATTERINO2_IMAGE_UPLOADER_URL",
|
||||||
"https://i.nuuls.com/upload"))
|
"https://i.nuuls.com/upload"))
|
||||||
|
, imageUploaderFormBody(
|
||||||
|
readStringEnv("CHATTERINO2_IMAGE_UPLOADER_FORM_BODY", "attachment"))
|
||||||
, twitchServerHost(
|
, twitchServerHost(
|
||||||
readStringEnv("CHATTERINO2_TWITCH_SERVER_HOST", "irc.chat.twitch.tv"))
|
readStringEnv("CHATTERINO2_TWITCH_SERVER_HOST", "irc.chat.twitch.tv"))
|
||||||
, twitchServerPort(readPortEnv("CHATTERINO2_TWITCH_SERVER_PORT", 443))
|
, twitchServerPort(readPortEnv("CHATTERINO2_TWITCH_SERVER_PORT", 443))
|
||||||
|
|
|
@ -15,6 +15,7 @@ public:
|
||||||
const QString linkResolverUrl;
|
const QString linkResolverUrl;
|
||||||
const QString twitchEmoteSetResolverUrl;
|
const QString twitchEmoteSetResolverUrl;
|
||||||
const QString imageUploaderUrl;
|
const QString imageUploaderUrl;
|
||||||
|
const QString imageUploaderFormBody;
|
||||||
const QString twitchServerHost;
|
const QString twitchServerHost;
|
||||||
const uint16_t twitchServerPort;
|
const uint16_t twitchServerPort;
|
||||||
const bool twitchServerSecure;
|
const bool twitchServerSecure;
|
||||||
|
|
|
@ -43,6 +43,7 @@ void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel,
|
||||||
const static QString contentType =
|
const static QString contentType =
|
||||||
QString("multipart/form-data; boundary=%1").arg(boundary);
|
QString("multipart/form-data; boundary=%1").arg(boundary);
|
||||||
static QUrl url(Env::get().imageUploaderUrl);
|
static QUrl url(Env::get().imageUploaderUrl);
|
||||||
|
static QString formBody(Env::get().imageUploaderFormBody);
|
||||||
|
|
||||||
QHttpMultiPart *payload = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
QHttpMultiPart *payload = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||||
QHttpPart part = QHttpPart();
|
QHttpPart part = QHttpPart();
|
||||||
|
@ -51,10 +52,10 @@ void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel,
|
||||||
QString("image/%1").arg(imageData.format));
|
QString("image/%1").arg(imageData.format));
|
||||||
part.setHeader(QNetworkRequest::ContentLengthHeader,
|
part.setHeader(QNetworkRequest::ContentLengthHeader,
|
||||||
QVariant(imageData.data.length()));
|
QVariant(imageData.data.length()));
|
||||||
part.setHeader(
|
part.setHeader(QNetworkRequest::ContentDispositionHeader,
|
||||||
QNetworkRequest::ContentDispositionHeader,
|
QString("form-data; name=\"%1\"; filename=\"control_v.%2\"")
|
||||||
QString("form-data; name=\"attachment\"; filename=\"control_v.%1\"")
|
.arg(formBody)
|
||||||
.arg(imageData.format));
|
.arg(imageData.format));
|
||||||
payload->setBoundary(boundary);
|
payload->setBoundary(boundary);
|
||||||
payload->append(part);
|
payload->append(part);
|
||||||
NetworkRequest(url, NetworkRequestType::Post)
|
NetworkRequest(url, NetworkRequestType::Post)
|
||||||
|
|
Loading…
Reference in a new issue