Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FinClip
ligase
提交
7d17df6f
ligase
项目概览
FinClip
/
ligase
通知
38
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ligase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7d17df6f
编写于
7月 28, 2017
作者:
B
Brendan Abolivier
提交者:
Mark Haines
7月 28, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add local room join (#169)
* Add local room join * Update TODO
上级
34165c77
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
59 addition
and
10 deletion
+59
-10
src/github.com/matrix-org/dendrite/clientapi/routing/routing.go
...thub.com/matrix-org/dendrite/clientapi/routing/routing.go
+1
-1
src/github.com/matrix-org/dendrite/clientapi/writers/joinroom.go
...hub.com/matrix-org/dendrite/clientapi/writers/joinroom.go
+58
-9
未找到文件。
src/github.com/matrix-org/dendrite/clientapi/routing/routing.go
浏览文件 @
7d17df6f
...
@@ -78,7 +78,7 @@ func Setup(
...
@@ -78,7 +78,7 @@ func Setup(
common
.
MakeAuthAPI
(
"join"
,
deviceDB
,
func
(
req
*
http
.
Request
,
device
*
authtypes
.
Device
)
util
.
JSONResponse
{
common
.
MakeAuthAPI
(
"join"
,
deviceDB
,
func
(
req
*
http
.
Request
,
device
*
authtypes
.
Device
)
util
.
JSONResponse
{
vars
:=
mux
.
Vars
(
req
)
vars
:=
mux
.
Vars
(
req
)
return
writers
.
JoinRoomByIDOrAlias
(
return
writers
.
JoinRoomByIDOrAlias
(
req
,
device
,
vars
[
"roomIDOrAlias"
],
cfg
,
federation
,
producer
,
queryAPI
,
keyRing
,
accountDB
,
req
,
device
,
vars
[
"roomIDOrAlias"
],
cfg
,
federation
,
producer
,
queryAPI
,
aliasAPI
,
keyRing
,
accountDB
,
)
)
}),
}),
)
)
...
...
src/github.com/matrix-org/dendrite/clientapi/writers/joinroom.go
浏览文件 @
7d17df6f
...
@@ -42,6 +42,7 @@ func JoinRoomByIDOrAlias(
...
@@ -42,6 +42,7 @@ func JoinRoomByIDOrAlias(
federation
*
gomatrixserverlib
.
FederationClient
,
federation
*
gomatrixserverlib
.
FederationClient
,
producer
*
producers
.
RoomserverProducer
,
producer
*
producers
.
RoomserverProducer
,
queryAPI
api
.
RoomserverQueryAPI
,
queryAPI
api
.
RoomserverQueryAPI
,
aliasAPI
api
.
RoomserverAliasAPI
,
keyRing
gomatrixserverlib
.
KeyRing
,
keyRing
gomatrixserverlib
.
KeyRing
,
accountDB
*
accounts
.
Database
,
accountDB
*
accounts
.
Database
,
)
util
.
JSONResponse
{
)
util
.
JSONResponse
{
...
@@ -64,7 +65,7 @@ func JoinRoomByIDOrAlias(
...
@@ -64,7 +65,7 @@ func JoinRoomByIDOrAlias(
content
[
"displayname"
]
=
profile
.
DisplayName
content
[
"displayname"
]
=
profile
.
DisplayName
content
[
"avatar_url"
]
=
profile
.
AvatarURL
content
[
"avatar_url"
]
=
profile
.
AvatarURL
r
:=
joinRoomReq
{
req
,
content
,
device
.
UserID
,
cfg
,
federation
,
producer
,
queryAPI
,
keyRing
}
r
:=
joinRoomReq
{
req
,
content
,
device
.
UserID
,
cfg
,
federation
,
producer
,
queryAPI
,
aliasAPI
,
keyRing
}
if
strings
.
HasPrefix
(
roomIDOrAlias
,
"!"
)
{
if
strings
.
HasPrefix
(
roomIDOrAlias
,
"!"
)
{
return
r
.
joinRoomByID
()
return
r
.
joinRoomByID
()
...
@@ -86,6 +87,7 @@ type joinRoomReq struct {
...
@@ -86,6 +87,7 @@ type joinRoomReq struct {
federation
*
gomatrixserverlib
.
FederationClient
federation
*
gomatrixserverlib
.
FederationClient
producer
*
producers
.
RoomserverProducer
producer
*
producers
.
RoomserverProducer
queryAPI
api
.
RoomserverQueryAPI
queryAPI
api
.
RoomserverQueryAPI
aliasAPI
api
.
RoomserverAliasAPI
keyRing
gomatrixserverlib
.
KeyRing
keyRing
gomatrixserverlib
.
KeyRing
}
}
...
@@ -111,11 +113,23 @@ func (r joinRoomReq) joinRoomByAlias(roomAlias string) util.JSONResponse {
...
@@ -111,11 +113,23 @@ func (r joinRoomReq) joinRoomByAlias(roomAlias string) util.JSONResponse {
}
}
}
}
if
domain
==
r
.
cfg
.
Matrix
.
ServerName
{
if
domain
==
r
.
cfg
.
Matrix
.
ServerName
{
// TODO: Implement joining local room aliases.
queryReq
:=
api
.
GetAliasRoomIDRequest
{
Alias
:
roomAlias
}
panic
(
fmt
.
Errorf
(
"Joining local room aliases is not implemented"
))
var
queryRes
api
.
GetAliasRoomIDResponse
}
else
{
if
err
=
r
.
aliasAPI
.
GetAliasRoomID
(
&
queryReq
,
&
queryRes
);
err
!=
nil
{
return
r
.
joinRoomByRemoteAlias
(
domain
,
roomAlias
)
return
httputil
.
LogThenError
(
r
.
req
,
err
)
}
}
if
len
(
queryRes
.
RoomID
)
>
0
{
return
r
.
joinRoomUsingServers
(
queryRes
.
RoomID
,
[]
gomatrixserverlib
.
ServerName
{
r
.
cfg
.
Matrix
.
ServerName
})
}
// If the response doesn't contain a non-empty string, return an error
return
util
.
JSONResponse
{
Code
:
404
,
JSON
:
jsonerror
.
NotFound
(
"Room alias "
+
roomAlias
+
" not found."
),
}
}
// If the room isn't local, use federation to join
return
r
.
joinRoomByRemoteAlias
(
domain
,
roomAlias
)
}
}
func
(
r
joinRoomReq
)
joinRoomByRemoteAlias
(
func
(
r
joinRoomReq
)
joinRoomByRemoteAlias
(
...
@@ -140,7 +154,7 @@ func (r joinRoomReq) joinRoomByRemoteAlias(
...
@@ -140,7 +154,7 @@ func (r joinRoomReq) joinRoomByRemoteAlias(
func
(
r
joinRoomReq
)
writeToBuilder
(
eb
*
gomatrixserverlib
.
EventBuilder
,
roomID
string
)
{
func
(
r
joinRoomReq
)
writeToBuilder
(
eb
*
gomatrixserverlib
.
EventBuilder
,
roomID
string
)
{
eb
.
Type
=
"m.room.member"
eb
.
Type
=
"m.room.member"
eb
.
SetContent
(
r
.
content
)
// TODO: Set avatar_url / displayname
eb
.
SetContent
(
r
.
content
)
eb
.
SetUnsigned
(
struct
{}{})
eb
.
SetUnsigned
(
struct
{}{})
eb
.
Sender
=
r
.
userID
eb
.
Sender
=
r
.
userID
eb
.
StateKey
=
&
r
.
userID
eb
.
StateKey
=
&
r
.
userID
...
@@ -170,9 +184,44 @@ func (r joinRoomReq) joinRoomUsingServers(
...
@@ -170,9 +184,44 @@ func (r joinRoomReq) joinRoomUsingServers(
}
}
if
queryRes
.
RoomExists
{
if
queryRes
.
RoomExists
{
// TODO: Implement joining rooms that already the server is already in.
// The room exists in the local database, so we just have to send a join
// This should just fall through to the usual event sending code.
// membership event and return the room ID
panic
(
fmt
.
Errorf
(
"Joining rooms that the server already in is not implemented"
))
// TODO: Check if the user is allowed in the room (has been invited if
// the room is invite-only)
eb
.
Depth
=
queryRes
.
Depth
eb
.
PrevEvents
=
queryRes
.
LatestEvents
authEvents
:=
gomatrixserverlib
.
NewAuthEvents
(
nil
)
for
i
:=
range
queryRes
.
StateEvents
{
authEvents
.
AddEvent
(
&
queryRes
.
StateEvents
[
i
])
}
refs
,
err
:=
needed
.
AuthEventReferences
(
&
authEvents
)
if
err
!=
nil
{
return
httputil
.
LogThenError
(
r
.
req
,
err
)
}
eb
.
AuthEvents
=
refs
now
:=
time
.
Now
()
eventID
:=
fmt
.
Sprintf
(
"$%s:%s"
,
util
.
RandomString
(
16
),
r
.
cfg
.
Matrix
.
ServerName
)
event
,
err
:=
eb
.
Build
(
eventID
,
now
,
r
.
cfg
.
Matrix
.
ServerName
,
r
.
cfg
.
Matrix
.
KeyID
,
r
.
cfg
.
Matrix
.
PrivateKey
,
)
if
err
!=
nil
{
return
httputil
.
LogThenError
(
r
.
req
,
err
)
}
if
err
:=
r
.
producer
.
SendEvents
([]
gomatrixserverlib
.
Event
{
event
},
r
.
cfg
.
Matrix
.
ServerName
);
err
!=
nil
{
return
httputil
.
LogThenError
(
r
.
req
,
err
)
}
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
struct
{
RoomID
string
`json:"room_id"`
}{
roomID
},
}
}
}
if
len
(
servers
)
==
0
{
if
len
(
servers
)
==
0
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录