MCPcopy Create free account
hub / github.com/daodst/chat / GetRoomIDForAlias

Method GetRoomIDForAlias

roomserver/internal/alias.go:80–116  ·  view source on GitHub ↗

GetRoomIDForAlias implements alias.RoomserverInternalAPI

(
	ctx context.Context,
	request *api.GetRoomIDForAliasRequest,
	response *api.GetRoomIDForAliasResponse,
)

Source from the content-addressed store, hash-verified

78
79// GetRoomIDForAlias implements alias.RoomserverInternalAPI
80func (r *RoomserverInternalAPI) GetRoomIDForAlias(
81 ctx context.Context,
82 request *api.GetRoomIDForAliasRequest,
83 response *api.GetRoomIDForAliasResponse,
84) error {
85 // Look up the room ID in the database
86 roomID, err := r.DB.GetRoomIDForAlias(ctx, request.Alias)
87 if err == nil && roomID != "" {
88 response.RoomID = roomID
89 return nil
90 }
91
92 // Check appservice on err, but only if the appservice API is
93 // wired in and no room ID was found.
94 if r.asAPI != nil && request.IncludeAppservices && roomID == "" {
95 // No room found locally, try our application services by making a call to
96 // the appservice component
97 aliasReq := &asAPI.RoomAliasExistsRequest{
98 Alias: request.Alias,
99 }
100 aliasRes := &asAPI.RoomAliasExistsResponse{}
101 if err = r.asAPI.RoomAliasExists(ctx, aliasReq, aliasRes); err != nil {
102 return err
103 }
104
105 if aliasRes.AliasExists {
106 roomID, err = r.DB.GetRoomIDForAlias(ctx, request.Alias)
107 if err != nil {
108 return err
109 }
110 response.RoomID = roomID
111 return nil
112 }
113 }
114
115 return err
116}
117
118// GetAliasesForRoomID implements alias.RoomserverInternalAPI
119func (r *RoomserverInternalAPI) GetAliasesForRoomID(

Callers

nothing calls this directly

Calls 2

GetRoomIDForAliasMethod · 0.65
RoomAliasExistsMethod · 0.65

Tested by

no test coverage detected