@@ -29,6 +29,16 @@ func GetChatIdFromBytes(buffer []byte) (ChatId, error) {
2929 return typed , nil
3030}
3131
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+
3242// GetChatIdFromProto gets a chat ID from the protobuf variant
3343func GetChatIdFromProto (proto * chatpb.ChatId ) (ChatId , error ) {
3444 if err := proto .Validate (); err != nil {
@@ -84,6 +94,16 @@ func GetMemberIdFromBytes(buffer []byte) (MemberId, error) {
8494 return typed , nil
8595}
8696
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+
87107// GetMemberIdFromProto gets a member ID from the protobuf variant
88108func GetMemberIdFromProto (proto * chatpb.ChatMemberId ) (MemberId , error ) {
89109 if err := proto .Validate (); err != nil {
@@ -171,6 +191,16 @@ func GetMessageIdFromBytes(buffer []byte) (MessageId, error) {
171191 return typed , nil
172192}
173193
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+
174204// GetMessageIdFromProto gets a message ID from the protobuf variant
175205func GetMessageIdFromProto (proto * chatpb.ChatMessageId ) (MessageId , error ) {
176206 if err := proto .Validate (); err != nil {
0 commit comments