Skip to content
Snippets Groups Projects
Unverified Commit add31670 authored by Sumner Evans's avatar Sumner Evans
Browse files

linkedingo: make NewURN generic over ~string

parent a2395759
No related branches found
No related tags found
No related merge requests found
Pipeline #16460 passed
......@@ -73,7 +73,7 @@ func NewLinkedInClient(ctx context.Context, lc *LinkedInConnector, login *bridge
}
client.client = linkedingo.NewClient(
ctx,
types.NewURN(string(login.ID)),
types.NewURN(login.ID),
login.Metadata.(*UserLoginMetadata).Cookies,
linkedingo.Handlers{
Heartbeat: func(ctx context.Context) {
......@@ -354,7 +354,7 @@ func (l *LinkedInClient) GetUserInfo(ctx context.Context, ghost *bridgev2.Ghost)
}
func (l *LinkedInClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.MatrixMessage) (*bridgev2.MatrixMessageResponse, error) {
conversationURN := types.NewURN(string(msg.Portal.ID))
conversationURN := types.NewURN(msg.Portal.ID)
sendMessagePayload := linkedingo.SendMessagePayload{
Message: linkedingo.SendMessage{
......@@ -433,11 +433,11 @@ func (l *LinkedInClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.
}
func (l *LinkedInClient) HandleMatrixEdit(ctx context.Context, msg *bridgev2.MatrixEdit) error {
return l.client.EditMessage(ctx, types.NewURN(string(msg.EditTarget.ID)), matrixfmt.Parse(ctx, l.matrixParser, msg.Content))
return l.client.EditMessage(ctx, types.NewURN(msg.EditTarget.ID), matrixfmt.Parse(ctx, l.matrixParser, msg.Content))
}
func (l *LinkedInClient) HandleMatrixMessageRemove(ctx context.Context, msg *bridgev2.MatrixMessageRemove) error {
return l.client.RecallMessage(ctx, types.NewURN(string(msg.TargetMessage.ID)))
return l.client.RecallMessage(ctx, types.NewURN(msg.TargetMessage.ID))
}
func (l *LinkedInClient) IsLoggedIn() bool {
......
......@@ -34,7 +34,7 @@ func toLinkedInAttribute(br linkedinfmt.BodyRange) linkedingo.SendMessageAttribu
Length: br.Length,
AttributeKindUnion: types.AttributeKind{
Entity: &types.Entity{
URN: types.NewURN(string(val.UserID)).WithPrefix("urn", "li", "fsd_profile"),
URN: types.NewURN(val.UserID).WithPrefix("urn", "li", "fsd_profile"),
},
},
}
......
......@@ -12,8 +12,8 @@ type URN struct {
idParts []string
}
func NewURN(urnStr string) (u URN) {
u.parts = strings.Split(urnStr, ":")
func NewURN[T ~string](s T) (u URN) {
u.parts = strings.Split(string(s), ":")
u.idParts = strings.Split(strings.Trim(u.parts[len(u.parts)-1], "()"), ",")
return
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment