-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial lark support
- Loading branch information
Showing
13 changed files
with
750 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package lark | ||
|
||
import ( | ||
validation "github.com/go-ozzo/ozzo-validation/v4" | ||
) | ||
|
||
type Config struct { | ||
Admin string `json:"admin"` | ||
AppID string `json:"app_id"` | ||
AppSecret string `json:"app_secret"` | ||
VerificationToken string `json:"verification_token"` | ||
EncryptKey string `json:"encrypt_key"` | ||
ProxyURL string `json:"proxy_url"` | ||
ProxyInsecure bool `json:"proxy_insecure"` | ||
} | ||
|
||
func (c Config) Validate() error { | ||
return validation.ValidateStruct(&c, | ||
validation.Field(&c.Admin, validation.Required), | ||
validation.Field(&c.AppID, validation.Required), | ||
validation.Field(&c.AppSecret, validation.Required), | ||
validation.Field(&c.VerificationToken, validation.Required), | ||
validation.Field(&c.EncryptKey), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package lark | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/russtone/sonar/internal/utils/errors" | ||
) | ||
|
||
type contextKey string | ||
|
||
const ( | ||
messageIDKey contextKey = "lark.messageID" | ||
) | ||
|
||
func GetMessageID(ctx context.Context) (*string, errors.Error) { | ||
id, ok := ctx.Value(messageIDKey).(string) | ||
if !ok { | ||
return nil, errors.Internalf("no %q key in context", messageIDKey) | ||
} | ||
return &id, nil | ||
} | ||
|
||
func SetMessageID(ctx context.Context, msgID string) context.Context { | ||
return context.WithValue(ctx, messageIDKey, msgID) | ||
} |
Oops, something went wrong.