mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
link
This commit is contained in:
parent
5fcb033167
commit
77ea204be0
|
@ -1987,6 +1987,29 @@ MessagePtr MessageBuilder::makeLowTrustUpdateMessage(
|
||||||
return builder.release();
|
return builder.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessagePtrMut MessageBuilder::makeAccountExpiredMessage(
|
||||||
|
const QString &expirationText)
|
||||||
|
{
|
||||||
|
auto loginPromptText = u"Try adding your account again."_s;
|
||||||
|
|
||||||
|
MessageBuilder builder;
|
||||||
|
auto text = expirationText % ' ' % loginPromptText;
|
||||||
|
builder->messageText = text;
|
||||||
|
builder->searchText = text;
|
||||||
|
builder->flags.set(MessageFlag::System,
|
||||||
|
MessageFlag::DoNotTriggerNotification);
|
||||||
|
|
||||||
|
builder.emplace<TimestampElement>();
|
||||||
|
builder.emplace<TextElement>(expirationText, MessageElementFlag::Text,
|
||||||
|
MessageColor::System);
|
||||||
|
builder
|
||||||
|
.emplace<TextElement>(loginPromptText, MessageElementFlag::Text,
|
||||||
|
MessageColor::Link)
|
||||||
|
->setLink({Link::OpenAccountsPage, {}});
|
||||||
|
|
||||||
|
return builder.release();
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<MessagePtrMut, HighlightAlert> MessageBuilder::makeIrcMessage(
|
std::pair<MessagePtrMut, HighlightAlert> MessageBuilder::makeIrcMessage(
|
||||||
/* mutable */ Channel *channel, const Communi::IrcMessage *ircMessage,
|
/* mutable */ Channel *channel, const Communi::IrcMessage *ircMessage,
|
||||||
const MessageParseArgs &args, /* mutable */ QString content,
|
const MessageParseArgs &args, /* mutable */ QString content,
|
||||||
|
|
|
@ -258,6 +258,9 @@ public:
|
||||||
const QVariantMap &tags,
|
const QVariantMap &tags,
|
||||||
const QTime &time);
|
const QTime &time);
|
||||||
|
|
||||||
|
static MessagePtrMut makeAccountExpiredMessage(
|
||||||
|
const QString &expirationText);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TextState {
|
struct TextState {
|
||||||
TwitchChannel *twitchChannel = nullptr;
|
TwitchChannel *twitchChannel = nullptr;
|
||||||
|
|
|
@ -230,29 +230,10 @@ MessagePtr parseNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
|
|
||||||
if (message->content().startsWith("Login auth", Qt::CaseInsensitive))
|
if (message->content().startsWith("Login auth", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
const auto linkColor = MessageColor(MessageColor::Link);
|
|
||||||
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
|
||||||
const auto curUser = getApp()->getAccounts()->twitch.getCurrent();
|
const auto curUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
const auto expirationText = QString("Login expired for user \"%1\"!")
|
|
||||||
.arg(curUser->getUserName());
|
|
||||||
const auto loginPromptText = QString("Try adding your account again.");
|
|
||||||
|
|
||||||
MessageBuilder builder;
|
return MessageBuilder::makeAccountExpiredMessage(
|
||||||
auto text = QString("%1 %2").arg(expirationText, loginPromptText);
|
u"Login expired for user \"" % curUser->getUserName() % u"\"!");
|
||||||
builder.message().messageText = text;
|
|
||||||
builder.message().searchText = text;
|
|
||||||
builder.message().flags.set(MessageFlag::System);
|
|
||||||
builder.message().flags.set(MessageFlag::DoNotTriggerNotification);
|
|
||||||
|
|
||||||
builder.emplace<TimestampElement>();
|
|
||||||
builder.emplace<TextElement>(expirationText, MessageElementFlag::Text,
|
|
||||||
MessageColor::System);
|
|
||||||
builder
|
|
||||||
.emplace<TextElement>(loginPromptText, MessageElementFlag::Text,
|
|
||||||
linkColor)
|
|
||||||
->setLink(accountsLink);
|
|
||||||
|
|
||||||
return builder.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message->content().startsWith("You are permanently banned "))
|
if (message->content().startsWith("You are permanently banned "))
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "common/network/NetworkResult.hpp"
|
#include "common/network/NetworkResult.hpp"
|
||||||
#include "common/Outcome.hpp"
|
#include "common/Outcome.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
@ -411,20 +412,28 @@ void TwitchAccountManager::refreshAccounts(bool emitChanged)
|
||||||
})
|
})
|
||||||
.onError([this, account](const auto &res) {
|
.onError([this, account](const auto &res) {
|
||||||
auto json = res.parseJson();
|
auto json = res.parseJson();
|
||||||
QString message =
|
QString message = u"Failed to refresh OAuth token for " %
|
||||||
u"Failed to refresh OAuth token for " %
|
account->getUserName() % u" (" %
|
||||||
account->getUserName() % u" error: " % res.formatError() %
|
res.formatError() % u" - " %
|
||||||
u" - " % json["message"_L1].toString(u"(no message)"_s);
|
json["message"_L1].toString(u"no message"_s) %
|
||||||
|
u").";
|
||||||
qCWarning(chatterinoTwitch) << message;
|
qCWarning(chatterinoTwitch) << message;
|
||||||
|
|
||||||
if (account == this->getCurrent())
|
if (account == this->getCurrent())
|
||||||
{
|
{
|
||||||
if (res.status().value_or(0) == 400) // invalid token
|
if (res.status().value_or(0) == 400) // invalid token
|
||||||
{
|
{
|
||||||
message +=
|
auto msg =
|
||||||
QStringView(u". Consider re-adding your account.");
|
MessageBuilder::makeAccountExpiredMessage(message);
|
||||||
|
getApp()->getTwitch()->forEachChannel(
|
||||||
|
[msg](const auto &chan) {
|
||||||
|
chan->addMessage(msg, MessageContext::Original);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getApp()->getTwitch()->addGlobalSystemMessage(message);
|
||||||
}
|
}
|
||||||
getApp()->getTwitch()->addGlobalSystemMessage(message);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(tryFlush)
|
.finally(tryFlush)
|
||||||
|
|
Loading…
Reference in a new issue