Primfeed improvements - from user feedback etc

Increased text length from 700 to 5000.
The OAUTH secret is no longer sent to chat where it might be accidentally revealed.
cleaned up state management. Pending Auth can now be reset by clicking disconnect and the connecting again.
master
Beq 2025-05-23 03:44:13 +01:00
parent 53909d14c3
commit 29e821a8d0
5 changed files with 28 additions and 36 deletions

View File

@ -540,6 +540,8 @@ void FSPrimfeedPhotoPanel::onOpen(const LLSD& key)
{
// Reauthorise if necessary.
FSPrimfeedAuth::initiateAuthRequest();
LLSD dummy;
onPrimfeedConnectStateChange(dummy);
}
}
@ -662,15 +664,14 @@ bool FSPrimfeedAccountPanel::postBuild()
void FSPrimfeedAccountPanel::draw()
{
FSPrimfeedConnect::EConnectionState connection_state = FSPrimfeedConnect::instance().getConnectionState();
static FSPrimfeedConnect::EConnectionState last_state = FSPrimfeedConnect::PRIMFEED_DISCONNECTED;
// Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress
bool disconnecting = connection_state == FSPrimfeedConnect::PRIMFEED_DISCONNECTING;
mDisconnectButton->setEnabled(!disconnecting);
// Disable the 'connect' button when a connection is in progress
bool connecting =
(connection_state == FSPrimfeedConnect::PRIMFEED_CONNECTING || connection_state == FSPrimfeedConnect::PRIMFEED_CONNECTED);
mConnectButton->setEnabled(!connecting);
// Update the connection state if it has changed
if (connection_state != last_state)
{
onPrimfeedConnectStateChange(LLSD());
last_state = connection_state;
}
LLPanel::draw();
}
@ -703,7 +704,7 @@ void FSPrimfeedAccountPanel::onVisibilityChange(bool visible)
bool FSPrimfeedAccountPanel::onPrimfeedConnectStateChange(const LLSD&)
{
if (FSPrimfeedAuth::isAuthorized())
if (FSPrimfeedAuth::isAuthorized() || FSPrimfeedConnect::instance().getConnectionState() == FSPrimfeedConnect::PRIMFEED_CONNECTING)
{
showConnectedLayout();
}
@ -770,11 +771,15 @@ void FSPrimfeedAccountPanel::showConnectedLayout()
void FSPrimfeedAccountPanel::onConnect()
{
FSPrimfeedAuth::initiateAuthRequest();
LLSD dummy;
onPrimfeedConnectStateChange(dummy);
}
void FSPrimfeedAccountPanel::onDisconnect()
{
FSPrimfeedAuth::resetAuthStatus();
LLSD dummy;
onPrimfeedConnectStateChange(dummy);
}
////////////////////////

View File

@ -131,6 +131,7 @@ void FSPrimfeedAuth::initiateAuthRequest()
sPrimfeedAuth.reset();
}
);
FSPrimfeedConnect::instance().setConnectionState(FSPrimfeedConnect::PRIMFEED_CONNECTING);
}
else
{
@ -149,20 +150,16 @@ void FSPrimfeedAuth::resetAuthStatus()
event_data["status"] = "reset";
event_data["success"] = "false";
sPrimfeedAuthPump->post(event_data);
FSPrimfeedConnect::instance().setConnectionState(FSPrimfeedConnect::PRIMFEED_DISCONNECTED);
}
FSPrimfeedAuth::FSPrimfeedAuth(authorized_callback_t callback)
: mCallback(callback), mAuthenticating(false)
: mCallback(callback)
{
mInstantMessageConnection = LLIMModel::instance().addNewMsgCallback(
[this](const LLSD &message) {
LL_DEBUGS("FSPrimfeedAuth") << "Received chat message: " << message["message"].asString() << LL_ENDL;
this->onChatMessage(message);
});
mChatMessageConnection = LLNotificationsUI::LLNotificationManager::instance().getChatHandler()->addNewChatCallback(
[this](const LLSD &message) {
LL_DEBUGS("FSPrimfeedAuth") << "Received instant message: " << message["message"].asString() << LL_ENDL;
LL_DEBUGS("FSPrimfeedAuth") << "Received chat message: " << message["message"].asString() << LL_ENDL;
this->onChatMessage(message);
});
}
@ -184,21 +181,6 @@ FSPrimfeedAuth::~FSPrimfeedAuth()
LL_WARNS("FSPrimfeedAuth") << "Unknown exception during chat connection disconnect." << LL_ENDL;
}
}
if (mInstantMessageConnection.connected())
{
try
{
mInstantMessageConnection.disconnect();
}
catch (const std::exception& e)
{
LL_WARNS("FSPrimfeedAuth") << "Exception during instant message disconnect: " << e.what() << LL_ENDL;
}
catch (...)
{
LL_WARNS("FSPrimfeedAuth") << "Unknown exception during instant message disconnect." << LL_ENDL;
}
}
}
// Factory method to create a shared pointer to FSPrimfeedAuth.
@ -216,7 +198,7 @@ std::shared_ptr<FSPrimfeedAuth> FSPrimfeedAuth::create(authorized_callback_t cal
return nullptr;
}
auth->mAuthenticating = true;
FSPrimfeedConnect::instance().setConnectionState(FSPrimfeedConnect::PRIMFEED_CONNECTING);
// If no token stored, begin the login request; otherwise check user status.
if (gSavedPerAccountSettings.getString("FSPrimfeedOAuthToken").empty())
@ -453,7 +435,6 @@ void FSPrimfeedAuth::gotUserStatus(bool success, const LLSD &response)
if (success && response.has("plan"))
{
gSavedPerAccountSettings.setString("FSPrimfeedOAuthToken", mOauthToken);
gSavedPerAccountSettings.setString("FSPrimfeedRequestId", mRequestId);
gSavedPerAccountSettings.setString("FSPrimfeedPlan", response["plan"].asString());
gSavedPerAccountSettings.setString("FSPrimfeedProfileLink", response["link"].asString());
gSavedPerAccountSettings.setString("FSPrimfeedUsername", response["username"].asString());

View File

@ -69,7 +69,6 @@ private:
explicit FSPrimfeedAuth(authorized_callback_t callback);
authorized_callback_t mCallback;
bool mAuthenticating;
std::string mOauthToken;
std::string mRequestId;

View File

@ -670,7 +670,14 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
}
}
// <FS:Beq> Hide Primfeed OAuth message from chat to prevent accidental leak of secret.
const std::string primfeed_oauth = "#PRIMFEED_OAUTH: ";
if( chat_msg.mText.compare(0, primfeed_oauth.length(), primfeed_oauth) == 0 && chat_msg.mChatType == CHAT_TYPE_IM && chat_msg.mSourceType == CHAT_SOURCE_OBJECT )
{
// Don't show the message in chat.
return;
}
// </FS:Beq>
nearby_chat->addMessage(chat_msg, true, args);
if (chat_msg.mSourceType == CHAT_SOURCE_AGENT

View File

@ -214,7 +214,7 @@
left="10"
length="1"
top_pad="0"
max_length="700"
max_length="5000"
name="photo_description"
spellcheck="true"
type="string"