From 45bf048c47cddb7aaebd6dd3778d6379a219fec7 Mon Sep 17 00:00:00 2001 From: furu04 Date: Tue, 13 Jan 2026 16:55:14 +0900 Subject: [PATCH] =?UTF-8?q?LINE=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/SPECIFICATION.md | 8 ++-- internal/handler/profile_handler.go | 2 - internal/models/notification_settings.go | 19 ++++----- internal/service/notification_service.go | 53 +----------------------- web/templates/pages/profile.html | 16 ------- 5 files changed, 13 insertions(+), 85 deletions(-) diff --git a/docs/SPECIFICATION.md b/docs/SPECIFICATION.md index 33f4f3b..5ddc7bd 100644 --- a/docs/SPECIFICATION.md +++ b/docs/SPECIFICATION.md @@ -115,8 +115,7 @@ homework-manager/ | UserID | uint | ユーザーID | Unique, Not Null | | TelegramEnabled | bool | Telegram通知 | Default: false | | TelegramChatID | string | Telegram Chat ID | - | -| LineEnabled | bool | LINE通知 | Default: false | -| LineNotifyToken | string | LINE Notifyトークン | - | +| NotifyOnCreate | bool | 課題追加時に通知 | Default: true | | CreatedAt | time.Time | 作成日時 | 自動設定 | | UpdatedAt | time.Time | 更新日時 | 自動更新 | | DeletedAt | gorm.DeletedAt | 論理削除日時 | ソフトデリート | @@ -207,7 +206,7 @@ REST API認証用のAPIキーを管理するモデル。 | 項目 | 説明 | |------|------| | 設定 | 課題登録・編集画面で通知日時を指定 | -| 送信 | 指定日時にTelegram/LINEで通知 | +| 送信 | 指定日時にTelegramで通知 | #### 4.4.2 督促通知 @@ -226,7 +225,6 @@ REST API認証用のAPIキーを管理するモデル。 | チャンネル | 設定方法 | |------------|----------| | Telegram | config.iniでBot Token設定、プロフィールでChat ID入力 | -| LINE Notify | プロフィールでアクセストークン入力 | ### 4.5 プロフィール機能 @@ -235,7 +233,7 @@ REST API認証用のAPIキーを管理するモデル。 | プロフィール表示 | ユーザー情報を表示 | | プロフィール更新 | 表示名を変更 | | パスワード変更 | 現在のパスワードを確認後、新しいパスワードに変更 | -| 通知設定 | Telegram/LINE通知の有効化とトークン設定 | +| 通知設定 | Telegram通知の有効化とトークン設定 | ### 4.6 管理者機能 diff --git a/internal/handler/profile_handler.go b/internal/handler/profile_handler.go index 9d4df11..d16ecbe 100644 --- a/internal/handler/profile_handler.go +++ b/internal/handler/profile_handler.go @@ -143,8 +143,6 @@ func (h *ProfileHandler) UpdateNotificationSettings(c *gin.Context) { settings := &models.UserNotificationSettings{ TelegramEnabled: c.PostForm("telegram_enabled") == "on", TelegramChatID: c.PostForm("telegram_chat_id"), - LineEnabled: c.PostForm("line_enabled") == "on", - LineNotifyToken: c.PostForm("line_token"), NotifyOnCreate: c.PostForm("notify_on_create") == "on", } diff --git a/internal/models/notification_settings.go b/internal/models/notification_settings.go index d9a45f0..26467fb 100644 --- a/internal/models/notification_settings.go +++ b/internal/models/notification_settings.go @@ -7,16 +7,15 @@ import ( ) type UserNotificationSettings struct { - ID uint `gorm:"primarykey" json:"id"` - UserID uint `gorm:"uniqueIndex;not null" json:"user_id"` - TelegramEnabled bool `gorm:"default:false" json:"telegram_enabled"` - TelegramChatID string `json:"telegram_chat_id"` - LineEnabled bool `gorm:"default:false" json:"line_enabled"` - LineNotifyToken string `json:"-"` - NotifyOnCreate bool `gorm:"default:true" json:"notify_on_create"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` - DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` + ID uint `gorm:"primarykey" json:"id"` + UserID uint `gorm:"uniqueIndex;not null" json:"user_id"` + TelegramEnabled bool `gorm:"default:false" json:"telegram_enabled"` + TelegramChatID string `json:"telegram_chat_id"` + + NotifyOnCreate bool `gorm:"default:true" json:"notify_on_create"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` User *User `gorm:"foreignKey:UserID" json:"-"` } diff --git a/internal/service/notification_service.go b/internal/service/notification_service.go index 4074380..46599ea 100644 --- a/internal/service/notification_service.go +++ b/internal/service/notification_service.go @@ -6,7 +6,6 @@ import ( "fmt" "log" "net/http" - "net/url" "strings" "time" @@ -85,38 +84,6 @@ func (s *NotificationService) SendTelegramNotification(chatID, message string) e return nil } -func (s *NotificationService) SendLineNotification(token, message string) error { - if token == "" { - return fmt.Errorf("LINE Notify token is empty") - } - - apiURL := "https://notify-api.line.me/api/notify" - - data := url.Values{} - data.Set("message", message) - - req, err := http.NewRequest("POST", apiURL, strings.NewReader(data.Encode())) - if err != nil { - return err - } - - req.Header.Set("Authorization", "Bearer "+token) - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - - client := &http.Client{Timeout: 10 * time.Second} - resp, err := client.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("LINE Notify API returned status %d", resp.StatusCode) - } - - return nil -} - func (s *NotificationService) SendAssignmentReminder(userID uint, assignment *models.Assignment) error { settings, err := s.GetUserSettings(userID) if err != nil { @@ -139,12 +106,6 @@ func (s *NotificationService) SendAssignmentReminder(userID uint, assignment *mo } } - if settings.LineEnabled && settings.LineNotifyToken != "" { - if err := s.SendLineNotification(settings.LineNotifyToken, message); err != nil { - errors = append(errors, fmt.Sprintf("LINE: %v", err)) - } - } - if len(errors) > 0 { return fmt.Errorf("notification errors: %s", strings.Join(errors, "; ")) } @@ -162,7 +123,7 @@ func (s *NotificationService) SendAssignmentCreatedNotification(userID uint, ass return nil } - if !settings.TelegramEnabled && !settings.LineEnabled { + if !settings.TelegramEnabled { return nil } @@ -183,12 +144,6 @@ func (s *NotificationService) SendAssignmentCreatedNotification(userID uint, ass } } - if settings.LineEnabled && settings.LineNotifyToken != "" { - if err := s.SendLineNotification(settings.LineNotifyToken, message); err != nil { - errors = append(errors, fmt.Sprintf("LINE: %v", err)) - } - } - if len(errors) > 0 { return fmt.Errorf("notification errors: %s", strings.Join(errors, "; ")) } @@ -252,12 +207,6 @@ func (s *NotificationService) SendUrgentReminder(userID uint, assignment *models } } - if settings.LineEnabled && settings.LineNotifyToken != "" { - if err := s.SendLineNotification(settings.LineNotifyToken, message); err != nil { - errors = append(errors, fmt.Sprintf("LINE: %v", err)) - } - } - if len(errors) > 0 { return fmt.Errorf("notification errors: %s", strings.Join(errors, "; ")) } diff --git a/web/templates/pages/profile.html b/web/templates/pages/profile.html index f1e5336..18bfe16 100644 --- a/web/templates/pages/profile.html +++ b/web/templates/pages/profile.html @@ -95,22 +95,6 @@ -
-
LINE Notify
-
- - -
-
- - -
- LINE Notifyでトークンを発行 -
-
-