@@ -29,6 +29,16 @@ func GetChatIdFromBytes(buffer []byte) (ChatId, error) {
29
29
return typed , nil
30
30
}
31
31
32
+ // GetChatIdFromBytes gets a chat ID from the string representation
33
+ func GetChatIdFromString (value string ) (ChatId , error ) {
34
+ decoded , err := hex .DecodeString (value )
35
+ if err != nil {
36
+ return ChatId {}, errors .Wrap (err , "value is not a hexadecimal string" )
37
+ }
38
+
39
+ return GetChatIdFromBytes (decoded )
40
+ }
41
+
32
42
// GetChatIdFromProto gets a chat ID from the protobuf variant
33
43
func GetChatIdFromProto (proto * chatpb.ChatId ) (ChatId , error ) {
34
44
if err := proto .Validate (); err != nil {
@@ -84,6 +94,16 @@ func GetMemberIdFromBytes(buffer []byte) (MemberId, error) {
84
94
return typed , nil
85
95
}
86
96
97
+ // GetMemberIdFromString gets a chat member ID from the string representation
98
+ func GetMemberIdFromString (value string ) (MemberId , error ) {
99
+ decoded , err := uuid .Parse (value )
100
+ if err != nil {
101
+ return MemberId {}, errors .Wrap (err , "value is not a uuid string" )
102
+ }
103
+
104
+ return GetMemberIdFromBytes (decoded [:])
105
+ }
106
+
87
107
// GetMemberIdFromProto gets a member ID from the protobuf variant
88
108
func GetMemberIdFromProto (proto * chatpb.ChatMemberId ) (MemberId , error ) {
89
109
if err := proto .Validate (); err != nil {
@@ -171,6 +191,16 @@ func GetMessageIdFromBytes(buffer []byte) (MessageId, error) {
171
191
return typed , nil
172
192
}
173
193
194
+ // GetMessageIdFromString gets a chat message ID from the string representation
195
+ func GetMessageIdFromString (value string ) (MessageId , error ) {
196
+ decoded , err := uuid .Parse (value )
197
+ if err != nil {
198
+ return MessageId {}, errors .Wrap (err , "value is not a uuid string" )
199
+ }
200
+
201
+ return GetMessageIdFromBytes (decoded [:])
202
+ }
203
+
174
204
// GetMessageIdFromProto gets a message ID from the protobuf variant
175
205
func GetMessageIdFromProto (proto * chatpb.ChatMessageId ) (MessageId , error ) {
176
206
if err := proto .Validate (); err != nil {
0 commit comments