2016-11-30 11:46:33 +00:00
package gomatrix
2016-12-01 12:19:25 +00:00
// RespError is the standard JSON error response from Homeservers. It also implements the Golang "error" interface.
// See http://matrix.org/docs/spec/client_server/r0.2.0.html#api-standards
type RespError struct {
ErrCode string ` json:"errcode" `
Err string ` json:"error" `
}
// Error returns the errcode and error message.
func ( e RespError ) Error ( ) string {
return e . ErrCode + ": " + e . Err
}
2016-11-30 11:46:33 +00:00
// RespCreateFilter is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter
type RespCreateFilter struct {
FilterID string ` json:"filter_id" `
}
2017-01-05 12:58:55 +00:00
// RespVersions is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-versions
type RespVersions struct {
Versions [ ] string ` json:"versions" `
}
2019-12-21 22:26:19 +00:00
// RespPublicRooms is the JSON response for http://matrix.org/speculator/spec/HEAD/client_server/unstable.html#get-matrix-client-unstable-publicrooms
type RespPublicRooms struct {
2019-12-21 22:33:03 +00:00
TotalRoomCountEstimate int ` json:"total_room_count_estimate" `
PrevBatch string ` json:"prev_batch" `
NextBatch string ` json:"next_batch" `
Chunk [ ] PublicRoom ` json:"chunk" `
2019-12-21 22:26:19 +00:00
}
2016-11-30 11:46:33 +00:00
// RespJoinRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-join
type RespJoinRoom struct {
RoomID string ` json:"room_id" `
}
2016-12-01 17:32:16 +00:00
// RespLeaveRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-leave
type RespLeaveRoom struct { }
2017-01-05 15:23:37 +00:00
// RespForgetRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-forget
type RespForgetRoom struct { }
// RespInviteUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite
type RespInviteUser struct { }
// RespKickUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick
type RespKickUser struct { }
// RespBanUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban
type RespBanUser struct { }
// RespUnbanUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban
type RespUnbanUser struct { }
2017-04-25 09:11:59 +00:00
// RespTyping is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid
type RespTyping struct { }
2017-01-06 14:39:25 +00:00
// RespJoinedRooms is the JSON response for TODO-SPEC https://github.com/matrix-org/synapse/pull/1680
type RespJoinedRooms struct {
JoinedRooms [ ] string ` json:"joined_rooms" `
}
// RespJoinedMembers is the JSON response for TODO-SPEC https://github.com/matrix-org/synapse/pull/1680
type RespJoinedMembers struct {
Joined map [ string ] struct {
DisplayName * string ` json:"display_name" `
AvatarURL * string ` json:"avatar_url" `
} ` json:"joined" `
}
2017-05-07 04:21:07 +00:00
// RespMessages is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages
type RespMessages struct {
Start string ` json:"start" `
Chunk [ ] Event ` json:"chunk" `
End string ` json:"end" `
}
2016-11-30 11:46:33 +00:00
// RespSendEvent is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid
type RespSendEvent struct {
EventID string ` json:"event_id" `
}
2016-12-01 12:19:25 +00:00
// RespMediaUpload is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload
type RespMediaUpload struct {
ContentURI string ` json:"content_uri" `
}
2016-12-02 16:51:20 +00:00
// RespUserInteractive is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#user-interactive-authentication-api
type RespUserInteractive struct {
Flows [ ] struct {
Stages [ ] string ` json:"stages" `
} ` json:"flows" `
2016-12-02 17:02:25 +00:00
Params map [ string ] interface { } ` json:"params" `
2018-12-13 12:23:14 +00:00
Session string ` json:"session" `
2016-12-02 17:02:25 +00:00
Completed [ ] string ` json:"completed" `
ErrCode string ` json:"errcode" `
Error string ` json:"error" `
2016-12-02 16:51:20 +00:00
}
2016-12-02 17:13:10 +00:00
// HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName.
func ( r RespUserInteractive ) HasSingleStageFlow ( stageName string ) bool {
for _ , f := range r . Flows {
if len ( f . Stages ) == 1 && f . Stages [ 0 ] == stageName {
return true
}
}
return false
}
2017-08-22 19:41:15 +00:00
// RespUserDisplayName is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname
type RespUserDisplayName struct {
DisplayName string ` json:"displayname" `
}
2020-08-27 12:07:42 +00:00
// RespUserStatus is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-presence-userid-status
type RespUserStatus struct {
Presence string ` json:"presence" `
StatusMsg string ` json:"status_msg" `
LastActiveAgo int ` json:"last_active_ago" `
CurrentlyActive bool ` json:"currently_active" `
}
2016-12-02 16:51:20 +00:00
// RespRegister is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register
type RespRegister struct {
AccessToken string ` json:"access_token" `
DeviceID string ` json:"device_id" `
HomeServer string ` json:"home_server" `
RefreshToken string ` json:"refresh_token" `
UserID string ` json:"user_id" `
}
2020-08-27 12:05:45 +00:00
// RespLogin is the JSON response for http://matrix.org/docs/spec/client_server/r0.6.0.html#post-matrix-client-r0-login
2016-12-09 15:03:19 +00:00
type RespLogin struct {
2020-08-27 12:05:45 +00:00
AccessToken string ` json:"access_token" `
DeviceID string ` json:"device_id" `
HomeServer string ` json:"home_server" `
UserID string ` json:"user_id" `
WellKnown DiscoveryInformation ` json:"well_known" `
2016-12-09 15:03:19 +00:00
}
2020-08-27 12:05:45 +00:00
// DiscoveryInformation is the JSON Response for https://matrix.org/docs/spec/client_server/r0.6.0#get-well-known-matrix-client and a part of the JSON Response for https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-login
type DiscoveryInformation struct {
Homeserver struct {
BaseURL string ` json:"base_url" `
} ` json:"m.homeserver" `
IdentityServer struct {
BaseURL string ` json:"base_url" `
} ` json:"m.identitiy_server" `
}
// RespLogout is the JSON response for http://matrix.org/docs/spec/client_server/r0.6.0.html#post-matrix-client-r0-logout
2017-01-05 14:16:47 +00:00
type RespLogout struct { }
2020-08-27 12:05:45 +00:00
// RespLogoutAll is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-logout-all
type RespLogoutAll struct { }
2016-12-09 15:42:32 +00:00
// RespCreateRoom is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom
type RespCreateRoom struct {
RoomID string ` json:"room_id" `
}
2016-11-30 11:46:33 +00:00
// RespSync is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync
type RespSync struct {
NextBatch string ` json:"next_batch" `
AccountData struct {
Events [ ] Event ` json:"events" `
} ` json:"account_data" `
Presence struct {
Events [ ] Event ` json:"events" `
} ` json:"presence" `
Rooms struct {
2017-04-19 23:19:23 +00:00
Leave map [ string ] struct {
State struct {
Events [ ] Event ` json:"events" `
} ` json:"state" `
Timeline struct {
Events [ ] Event ` json:"events" `
Limited bool ` json:"limited" `
PrevBatch string ` json:"prev_batch" `
} ` json:"timeline" `
} ` json:"leave" `
2016-11-30 11:46:33 +00:00
Join map [ string ] struct {
State struct {
Events [ ] Event ` json:"events" `
} ` json:"state" `
Timeline struct {
Events [ ] Event ` json:"events" `
Limited bool ` json:"limited" `
PrevBatch string ` json:"prev_batch" `
} ` json:"timeline" `
2020-08-27 12:22:06 +00:00
Ephemeral struct {
Events [ ] Event ` json:"events" `
} ` json:"ephemeral" `
2016-11-30 11:46:33 +00:00
} ` json:"join" `
Invite map [ string ] struct {
State struct {
Events [ ] Event
} ` json:"invite_state" `
} ` json:"invite" `
} ` json:"rooms" `
}
2017-06-07 13:09:49 +00:00
2019-01-30 11:32:41 +00:00
// RespTurnServer is the JSON response from a Turn Server
2017-06-07 13:09:49 +00:00
type RespTurnServer struct {
Username string ` json:"username" `
Password string ` json:"password" `
TTL int ` json:"ttl" `
URIs [ ] string ` json:"uris" `
}