diff options
author | Wim <wim@42.be> | 2022-03-20 01:43:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-20 01:43:26 +0100 |
commit | 17da95b094e4bb433e5fe240fa42067d94d908c1 (patch) | |
tree | 50abef4f2d92c1088d3a47c659bbc977a94f96b1 /vendor/github.com/matterbridge/gomatrix/identifier.go | |
parent | c5e49eec96a8b03786d679afa35c58952d0269a7 (diff) | |
download | matterbridge-msglm-17da95b094e4bb433e5fe240fa42067d94d908c1.tar.gz matterbridge-msglm-17da95b094e4bb433e5fe240fa42067d94d908c1.tar.bz2 matterbridge-msglm-17da95b094e4bb433e5fe240fa42067d94d908c1.zip |
Remove go replace by fork (matrix) (#1771)
Diffstat (limited to 'vendor/github.com/matterbridge/gomatrix/identifier.go')
-rw-r--r-- | vendor/github.com/matterbridge/gomatrix/identifier.go | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/github.com/matterbridge/gomatrix/identifier.go b/vendor/github.com/matterbridge/gomatrix/identifier.go new file mode 100644 index 00000000..4a61d080 --- /dev/null +++ b/vendor/github.com/matterbridge/gomatrix/identifier.go @@ -0,0 +1,69 @@ +package gomatrix + +// Identifier is the interface for https://matrix.org/docs/spec/client_server/r0.6.0#identifier-types +type Identifier interface { + // Returns the identifier type + // https://matrix.org/docs/spec/client_server/r0.6.0#identifier-types + Type() string +} + +// UserIdentifier is the Identifier for https://matrix.org/docs/spec/client_server/r0.6.0#matrix-user-id +type UserIdentifier struct { + IDType string `json:"type"` // Set by NewUserIdentifer + User string `json:"user"` +} + +// Type implements the Identifier interface +func (i UserIdentifier) Type() string { + return "m.id.user" +} + +// NewUserIdentifier creates a new UserIdentifier with IDType set to "m.id.user" +func NewUserIdentifier(user string) UserIdentifier { + return UserIdentifier{ + IDType: "m.id.user", + User: user, + } +} + +// ThirdpartyIdentifier is the Identifier for https://matrix.org/docs/spec/client_server/r0.6.0#third-party-id +type ThirdpartyIdentifier struct { + IDType string `json:"type"` // Set by NewThirdpartyIdentifier + Medium string `json:"medium"` + Address string `json:"address"` +} + +// Type implements the Identifier interface +func (i ThirdpartyIdentifier) Type() string { + return "m.id.thirdparty" +} + +// NewThirdpartyIdentifier creates a new UserIdentifier with IDType set to "m.id.user" +func NewThirdpartyIdentifier(medium, address string) ThirdpartyIdentifier { + return ThirdpartyIdentifier{ + IDType: "m.id.thirdparty", + Medium: medium, + Address: address, + } +} + +// PhoneIdentifier is the Identifier for https://matrix.org/docs/spec/client_server/r0.6.0#phone-number +type PhoneIdentifier struct { + IDType string `json:"type"` // Set by NewPhoneIdentifier + Country string `json:"country"` + Phone string `json:"phone"` +} + +// Type implements the Identifier interface +func (i PhoneIdentifier) Type() string { + return "m.id.phone" +} + +// NewPhoneIdentifier creates a new UserIdentifier with IDType set to "m.id.user" +func NewPhoneIdentifier(country, phone string) PhoneIdentifier { + return PhoneIdentifier{ + IDType: "m.id.phone", + Country: country, + Phone: phone, + } +} |