Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
6f8babc8
Verified
Commit
6f8babc8
authored
2 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Allow knocking if join failed and via matrix uris
parent
6417dcd3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#2927
failed
2 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ChatPage.cpp
+40
-8
40 additions, 8 deletions
src/ChatPage.cpp
src/ChatPage.h
+10
-1
10 additions, 1 deletion
src/ChatPage.h
with
50 additions
and
9 deletions
src/ChatPage.cpp
+
40
−
8
View file @
6f8babc8
...
...
@@ -127,6 +127,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
}
});
connect
(
this
,
&
ChatPage
::
internalKnock
,
this
,
qOverload
<
const
QString
&
,
const
std
::
vector
<
std
::
string
>
&
,
QString
,
bool
>
(
&
ChatPage
::
knockRoom
),
Qt
::
QueuedConnection
);
connect
(
this
,
&
ChatPage
::
leftRoom
,
this
,
&
ChatPage
::
removeRoom
);
connect
(
this
,
&
ChatPage
::
changeToRoom
,
this
,
&
ChatPage
::
changeRoom
,
Qt
::
QueuedConnection
);
connect
(
this
,
&
ChatPage
::
notificationsRetrieved
,
this
,
&
ChatPage
::
sendNotifications
);
...
...
@@ -659,17 +665,34 @@ ChatPage::trySync()
}
void
ChatPage
::
knockRoom
(
const
QString
&
room
,
const
QString
&
reason
)
ChatPage
::
knockRoom
(
const
QString
&
room
,
const
std
::
vector
<
std
::
string
>
&
via
,
QString
reason
,
bool
failedJoin
)
{
const
auto
room_id
=
room
.
toStdString
();
if
(
QMessageBox
::
Yes
!=
QMessageBox
::
question
(
nullptr
,
tr
(
"Confirm knock"
),
tr
(
"Do you really want to ask to join %1?"
).
arg
(
room
)))
bool
confirmed
=
false
;
reason
=
QInputDialog
::
getText
(
nullptr
,
tr
(
"Knock on room"
),
failedJoin
?
tr
(
"You failed to join %1. You can try to knock, so that others can invite you in. Do you "
"want to do so?
\n
You may optionally provide a reason for others to accept your knock:"
)
.
arg
(
room
)
:
tr
(
"Do you really want to knock on %1? You may optionally provide a reason for others to "
"accept your knock:"
)
.
arg
(
room
),
QLineEdit
::
Normal
,
reason
,
&
confirmed
);
if
(
!
confirmed
)
{
return
;
}
http
::
client
()
->
knock_room
(
room_id
,
{}
,
via
,
[
this
,
room_id
](
const
mtx
::
responses
::
RoomId
&
,
mtx
::
http
::
RequestErr
err
)
{
if
(
err
)
{
emit
showNotification
(
tr
(
"Failed to knock room: %1"
)
...
...
@@ -704,10 +727,13 @@ ChatPage::joinRoomVia(const std::string &room_id,
http
::
client
()
->
join_room
(
room_id
,
via
,
[
this
,
room_id
](
const
mtx
::
responses
::
RoomId
&
,
mtx
::
http
::
RequestErr
err
)
{
[
this
,
room_id
,
reason
,
via
](
const
mtx
::
responses
::
RoomId
&
,
mtx
::
http
::
RequestErr
err
)
{
if
(
err
)
{
emit
showNotification
(
tr
(
"Failed to join room: %1"
).
arg
(
QString
::
fromStdString
(
err
->
matrix_error
.
error
)));
if
(
err
->
matrix_error
.
errcode
==
mtx
::
errors
::
ErrorCode
::
M_FORBIDDEN
)
emit
internalKnock
(
QString
::
fromStdString
(
room_id
),
via
,
reason
,
true
);
else
emit
showNotification
(
tr
(
"Failed to join room: %1"
)
.
arg
(
QString
::
fromStdString
(
err
->
matrix_error
.
error
)));
return
;
}
...
...
@@ -1388,6 +1414,9 @@ ChatPage::handleMatrixUri(QString uri)
if
(
action
==
u"join"
||
action
.
isEmpty
())
{
joinRoomVia
(
targetRoomId
,
vias
);
return
true
;
}
else
if
(
action
==
u"knock"
||
action
.
isEmpty
())
{
knockRoom
(
mxid1
,
vias
);
return
true
;
}
return
false
;
}
else
if
(
sigil1
==
u"r"
)
{
...
...
@@ -1409,6 +1438,9 @@ ChatPage::handleMatrixUri(QString uri)
if
(
action
==
u"join"
||
action
.
isEmpty
())
{
joinRoomVia
(
mxid1
.
toStdString
(),
vias
);
return
true
;
}
else
if
(
action
==
u"knock"
||
action
.
isEmpty
())
{
knockRoom
(
mxid1
,
vias
);
return
true
;
}
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
src/ChatPage.h
+
10
−
1
View file @
6f8babc8
...
...
@@ -84,7 +84,11 @@ public slots:
void
leaveRoom
(
const
QString
&
room_id
,
const
QString
&
reason
);
void
createRoom
(
const
mtx
::
requests
::
CreateRoom
&
req
);
void
joinRoom
(
const
QString
&
room
,
const
QString
&
reason
=
""
);
void
knockRoom
(
const
QString
&
room
,
const
QString
&
reason
=
""
);
void
knockRoom
(
const
QString
&
room
,
QString
reason
=
""
)
{
knockRoom
(
room
,
{},
reason
,
false
);
}
void
knockRoom
(
const
QString
&
room
,
const
std
::
vector
<
std
::
string
>
&
via
,
QString
reason
=
""
,
bool
failedJoin
=
false
);
void
joinRoomVia
(
const
std
::
string
&
room_id
,
const
std
::
vector
<
std
::
string
>
&
via
,
bool
promptForConfirmation
=
true
,
...
...
@@ -161,6 +165,11 @@ signals:
void
downloadedSecrets
(
mtx
::
secret_storage
::
AesHmacSha2KeyDescription
keyDesc
,
const
SecretsToDecrypt
&
secrets
);
void
internalKnock
(
const
QString
&
room
,
const
std
::
vector
<
std
::
string
>
&
via
,
QString
reason
=
""
,
bool
failedJoin
=
false
);
private
slots
:
void
logout
();
void
removeRoom
(
const
QString
&
room_id
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment