Skip to content

Commit

Permalink
Add type when registering AS users
Browse files Browse the repository at this point in the history
Also renamed uk.half-shot.msc2778 constant to AuthTypeHalfyAppservice
  • Loading branch information
tulir committed Mar 4, 2021
1 parent 386db7f commit 2ab811a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions appservice/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (as *AppService) NewIntentAPI(localpart string) *IntentAPI {
func (intent *IntentAPI) Register() error {
_, _, err := intent.Client.Register(&mautrix.ReqRegister{
Username: intent.Localpart,
Type: mautrix.AuthTypeAppservice,
})
if err != nil {
return err
Expand Down
13 changes: 9 additions & 4 deletions requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const (
AuthTypeToken = "m.login.token"
AuthTypeDummy = "m.login.dummy"

AuthTypeAppservice = "uk.half-shot.msc2778.login.application_service"
AuthTypeAppservice = "m.login.application_service"
AuthTypeHalfyAppservice = "uk.half-shot.msc2778.login.application_service"
)

type IdentifierType string
Expand All @@ -34,16 +35,20 @@ const (
// ReqRegister is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register
type ReqRegister struct {
Username string `json:"username,omitempty"`
BindEmail bool `json:"bind_email,omitempty"`
Password string `json:"password,omitempty"`
DeviceID id.DeviceID `json:"device_id,omitempty"`
InitialDeviceDisplayName string `json:"initial_device_display_name"`
InitialDeviceDisplayName string `json:"initial_device_display_name,omitempty"`
InhibitLogin bool `json:"inhibit_login,omitempty"`
Auth interface{} `json:"auth,omitempty"`

// Type for registration, only used for appservice user registrations
// https://matrix.org/docs/spec/application_service/r0.1.2#server-admin-style-permissions
Type AuthType `json:"type"`
}

type BaseAuthData struct {
Type AuthType `json:"type"`
Session string `json:"session"`
Session string `json:"session,omitempty"`
}

type UserIdentifier struct {
Expand Down

0 comments on commit 2ab811a

Please sign in to comment.