mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update var-naming
This commit is contained in:
@@ -282,7 +282,7 @@ func (t *TelegramHandler) dispatchMemoRelatedWebhook(ctx context.Context, memo s
|
|||||||
for _, hook := range webhooks {
|
for _, hook := range webhooks {
|
||||||
payload := t.convertMemoToWebhookPayload(ctx, memo)
|
payload := t.convertMemoToWebhookPayload(ctx, memo)
|
||||||
payload.ActivityType = activityType
|
payload.ActivityType = activityType
|
||||||
payload.URL = hook.Url
|
payload.URL = hook.URL
|
||||||
err := webhook.Post(*payload)
|
err := webhook.Post(*payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to post webhook")
|
return errors.Wrap(err, "failed to post webhook")
|
||||||
|
@@ -823,7 +823,7 @@ func (s *APIV2Service) dispatchMemoRelatedWebhook(ctx context.Context, memo *api
|
|||||||
return errors.Wrap(err, "failed to convert memo to webhook payload")
|
return errors.Wrap(err, "failed to convert memo to webhook payload")
|
||||||
}
|
}
|
||||||
payload.ActivityType = activityType
|
payload.ActivityType = activityType
|
||||||
payload.URL = hook.Url
|
payload.URL = hook.URL
|
||||||
if err := webhook.Post(*payload); err != nil {
|
if err := webhook.Post(*payload); err != nil {
|
||||||
return errors.Wrap(err, "failed to post webhook")
|
return errors.Wrap(err, "failed to post webhook")
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ func (s *APIV2Service) CreateWebhook(ctx context.Context, request *apiv2pb.Creat
|
|||||||
webhook, err := s.Store.CreateWebhook(ctx, &store.Webhook{
|
webhook, err := s.Store.CreateWebhook(ctx, &store.Webhook{
|
||||||
CreatorID: currentUser.ID,
|
CreatorID: currentUser.ID,
|
||||||
Name: request.Name,
|
Name: request.Name,
|
||||||
Url: request.Url,
|
URL: request.Url,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to create webhook, error: %+v", err)
|
return nil, status.Errorf(codes.Internal, "failed to create webhook, error: %+v", err)
|
||||||
@@ -114,6 +114,6 @@ func convertWebhookFromStore(webhook *store.Webhook) *apiv2pb.Webhook {
|
|||||||
RowStatus: convertRowStatusFromStore(webhook.RowStatus),
|
RowStatus: convertRowStatusFromStore(webhook.RowStatus),
|
||||||
CreatorId: webhook.CreatorID,
|
CreatorId: webhook.CreatorID,
|
||||||
Name: webhook.Name,
|
Name: webhook.Name,
|
||||||
Url: webhook.Url,
|
Url: webhook.URL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ import (
|
|||||||
func (d *DB) CreateWebhook(ctx context.Context, create *store.Webhook) (*store.Webhook, error) {
|
func (d *DB) CreateWebhook(ctx context.Context, create *store.Webhook) (*store.Webhook, error) {
|
||||||
fields := []string{"`name`", "`url`", "`creator_id`"}
|
fields := []string{"`name`", "`url`", "`creator_id`"}
|
||||||
placeholder := []string{"?", "?", "?"}
|
placeholder := []string{"?", "?", "?"}
|
||||||
args := []any{create.Name, create.Url, create.CreatorID}
|
args := []any{create.Name, create.URL, create.CreatorID}
|
||||||
|
|
||||||
stmt := "INSERT INTO `webhook` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")"
|
stmt := "INSERT INTO `webhook` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")"
|
||||||
result, err := d.db.ExecContext(ctx, stmt, args...)
|
result, err := d.db.ExecContext(ctx, stmt, args...)
|
||||||
@@ -55,7 +55,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
|
|||||||
&rowStatus,
|
&rowStatus,
|
||||||
&webhook.CreatorID,
|
&webhook.CreatorID,
|
||||||
&webhook.Name,
|
&webhook.Name,
|
||||||
&webhook.Url,
|
&webhook.URL,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func (d *DB) CreateWebhook(ctx context.Context, create *store.Webhook) (*store.Webhook, error) {
|
func (d *DB) CreateWebhook(ctx context.Context, create *store.Webhook) (*store.Webhook, error) {
|
||||||
fields := []string{"name", "url", "creator_id"}
|
fields := []string{"name", "url", "creator_id"}
|
||||||
args := []any{create.Name, create.Url, create.CreatorID}
|
args := []any{create.Name, create.URL, create.CreatorID}
|
||||||
stmt := "INSERT INTO webhook (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts, row_status"
|
stmt := "INSERT INTO webhook (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts, row_status"
|
||||||
var rowStatus string
|
var rowStatus string
|
||||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||||
@@ -65,7 +65,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
|
|||||||
&rowStatus,
|
&rowStatus,
|
||||||
&webhook.CreatorID,
|
&webhook.CreatorID,
|
||||||
&webhook.Name,
|
&webhook.Name,
|
||||||
&webhook.Url,
|
&webhook.URL,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ func (d *DB) UpdateWebhook(ctx context.Context, update *store.UpdateWebhook) (*s
|
|||||||
&rowStatus,
|
&rowStatus,
|
||||||
&webhook.CreatorID,
|
&webhook.CreatorID,
|
||||||
&webhook.Name,
|
&webhook.Name,
|
||||||
&webhook.Url,
|
&webhook.URL,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ import (
|
|||||||
func (d *DB) CreateWebhook(ctx context.Context, create *store.Webhook) (*store.Webhook, error) {
|
func (d *DB) CreateWebhook(ctx context.Context, create *store.Webhook) (*store.Webhook, error) {
|
||||||
fields := []string{"`name`", "`url`", "`creator_id`"}
|
fields := []string{"`name`", "`url`", "`creator_id`"}
|
||||||
placeholder := []string{"?", "?", "?"}
|
placeholder := []string{"?", "?", "?"}
|
||||||
args := []any{create.Name, create.Url, create.CreatorID}
|
args := []any{create.Name, create.URL, create.CreatorID}
|
||||||
stmt := "INSERT INTO `webhook` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
|
stmt := "INSERT INTO `webhook` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
|
||||||
var rowStatus string
|
var rowStatus string
|
||||||
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
|
||||||
@@ -66,7 +66,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
|
|||||||
&rowStatus,
|
&rowStatus,
|
||||||
&webhook.CreatorID,
|
&webhook.CreatorID,
|
||||||
&webhook.Name,
|
&webhook.Name,
|
||||||
&webhook.Url,
|
&webhook.URL,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ func (d *DB) UpdateWebhook(ctx context.Context, update *store.UpdateWebhook) (*s
|
|||||||
&rowStatus,
|
&rowStatus,
|
||||||
&webhook.CreatorID,
|
&webhook.CreatorID,
|
||||||
&webhook.Name,
|
&webhook.Name,
|
||||||
&webhook.Url,
|
&webhook.URL,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ type Webhook struct {
|
|||||||
CreatorID int32
|
CreatorID int32
|
||||||
RowStatus RowStatus
|
RowStatus RowStatus
|
||||||
Name string
|
Name string
|
||||||
Url string
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type FindWebhook struct {
|
type FindWebhook struct {
|
||||||
|
@@ -17,7 +17,7 @@ func TestWebhookStore(t *testing.T) {
|
|||||||
webhook, err := ts.CreateWebhook(ctx, &store.Webhook{
|
webhook, err := ts.CreateWebhook(ctx, &store.Webhook{
|
||||||
CreatorID: user.ID,
|
CreatorID: user.ID,
|
||||||
Name: "test_webhook",
|
Name: "test_webhook",
|
||||||
Url: "https://example.com",
|
URL: "https://example.com",
|
||||||
RowStatus: store.Normal,
|
RowStatus: store.Normal,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
Reference in New Issue
Block a user