LINEを削除
This commit is contained in:
@@ -115,8 +115,7 @@ homework-manager/
|
|||||||
| UserID | uint | ユーザーID | Unique, Not Null |
|
| UserID | uint | ユーザーID | Unique, Not Null |
|
||||||
| TelegramEnabled | bool | Telegram通知 | Default: false |
|
| TelegramEnabled | bool | Telegram通知 | Default: false |
|
||||||
| TelegramChatID | string | Telegram Chat ID | - |
|
| TelegramChatID | string | Telegram Chat ID | - |
|
||||||
| LineEnabled | bool | LINE通知 | Default: false |
|
| NotifyOnCreate | bool | 課題追加時に通知 | Default: true |
|
||||||
| LineNotifyToken | string | LINE Notifyトークン | - |
|
|
||||||
| CreatedAt | time.Time | 作成日時 | 自動設定 |
|
| CreatedAt | time.Time | 作成日時 | 自動設定 |
|
||||||
| UpdatedAt | time.Time | 更新日時 | 自動更新 |
|
| UpdatedAt | time.Time | 更新日時 | 自動更新 |
|
||||||
| DeletedAt | gorm.DeletedAt | 論理削除日時 | ソフトデリート |
|
| DeletedAt | gorm.DeletedAt | 論理削除日時 | ソフトデリート |
|
||||||
@@ -207,7 +206,7 @@ REST API認証用のAPIキーを管理するモデル。
|
|||||||
| 項目 | 説明 |
|
| 項目 | 説明 |
|
||||||
|------|------|
|
|------|------|
|
||||||
| 設定 | 課題登録・編集画面で通知日時を指定 |
|
| 設定 | 課題登録・編集画面で通知日時を指定 |
|
||||||
| 送信 | 指定日時にTelegram/LINEで通知 |
|
| 送信 | 指定日時にTelegramで通知 |
|
||||||
|
|
||||||
#### 4.4.2 督促通知
|
#### 4.4.2 督促通知
|
||||||
|
|
||||||
@@ -226,7 +225,6 @@ REST API認証用のAPIキーを管理するモデル。
|
|||||||
| チャンネル | 設定方法 |
|
| チャンネル | 設定方法 |
|
||||||
|------------|----------|
|
|------------|----------|
|
||||||
| Telegram | config.iniでBot Token設定、プロフィールでChat ID入力 |
|
| Telegram | config.iniでBot Token設定、プロフィールでChat ID入力 |
|
||||||
| LINE Notify | プロフィールでアクセストークン入力 |
|
|
||||||
|
|
||||||
### 4.5 プロフィール機能
|
### 4.5 プロフィール機能
|
||||||
|
|
||||||
@@ -235,7 +233,7 @@ REST API認証用のAPIキーを管理するモデル。
|
|||||||
| プロフィール表示 | ユーザー情報を表示 |
|
| プロフィール表示 | ユーザー情報を表示 |
|
||||||
| プロフィール更新 | 表示名を変更 |
|
| プロフィール更新 | 表示名を変更 |
|
||||||
| パスワード変更 | 現在のパスワードを確認後、新しいパスワードに変更 |
|
| パスワード変更 | 現在のパスワードを確認後、新しいパスワードに変更 |
|
||||||
| 通知設定 | Telegram/LINE通知の有効化とトークン設定 |
|
| 通知設定 | Telegram通知の有効化とトークン設定 |
|
||||||
|
|
||||||
### 4.6 管理者機能
|
### 4.6 管理者機能
|
||||||
|
|
||||||
|
|||||||
@@ -143,8 +143,6 @@ func (h *ProfileHandler) UpdateNotificationSettings(c *gin.Context) {
|
|||||||
settings := &models.UserNotificationSettings{
|
settings := &models.UserNotificationSettings{
|
||||||
TelegramEnabled: c.PostForm("telegram_enabled") == "on",
|
TelegramEnabled: c.PostForm("telegram_enabled") == "on",
|
||||||
TelegramChatID: c.PostForm("telegram_chat_id"),
|
TelegramChatID: c.PostForm("telegram_chat_id"),
|
||||||
LineEnabled: c.PostForm("line_enabled") == "on",
|
|
||||||
LineNotifyToken: c.PostForm("line_token"),
|
|
||||||
NotifyOnCreate: c.PostForm("notify_on_create") == "on",
|
NotifyOnCreate: c.PostForm("notify_on_create") == "on",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ type UserNotificationSettings struct {
|
|||||||
UserID uint `gorm:"uniqueIndex;not null" json:"user_id"`
|
UserID uint `gorm:"uniqueIndex;not null" json:"user_id"`
|
||||||
TelegramEnabled bool `gorm:"default:false" json:"telegram_enabled"`
|
TelegramEnabled bool `gorm:"default:false" json:"telegram_enabled"`
|
||||||
TelegramChatID string `json:"telegram_chat_id"`
|
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"`
|
NotifyOnCreate bool `gorm:"default:true" json:"notify_on_create"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -85,38 +84,6 @@ func (s *NotificationService) SendTelegramNotification(chatID, message string) e
|
|||||||
return nil
|
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 {
|
func (s *NotificationService) SendAssignmentReminder(userID uint, assignment *models.Assignment) error {
|
||||||
settings, err := s.GetUserSettings(userID)
|
settings, err := s.GetUserSettings(userID)
|
||||||
if err != nil {
|
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 {
|
if len(errors) > 0 {
|
||||||
return fmt.Errorf("notification errors: %s", strings.Join(errors, "; "))
|
return fmt.Errorf("notification errors: %s", strings.Join(errors, "; "))
|
||||||
}
|
}
|
||||||
@@ -162,7 +123,7 @@ func (s *NotificationService) SendAssignmentCreatedNotification(userID uint, ass
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !settings.TelegramEnabled && !settings.LineEnabled {
|
if !settings.TelegramEnabled {
|
||||||
return nil
|
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 {
|
if len(errors) > 0 {
|
||||||
return fmt.Errorf("notification errors: %s", strings.Join(errors, "; "))
|
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 {
|
if len(errors) > 0 {
|
||||||
return fmt.Errorf("notification errors: %s", strings.Join(errors, "; "))
|
return fmt.Errorf("notification errors: %s", strings.Join(errors, "; "))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,22 +95,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
|
||||||
<h6 class="mb-3"><i class="bi bi-chat-dots me-1"></i>LINE Notify</h6>
|
|
||||||
<div class="form-check form-switch mb-2">
|
|
||||||
<input class="form-check-input" type="checkbox" id="line_enabled" name="line_enabled"
|
|
||||||
{{if .notifySettings.LineEnabled}}checked{{end}}>
|
|
||||||
<label class="form-check-label" for="line_enabled">LINE通知を有効化</label>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="line_token" class="form-label">アクセストークン</label>
|
|
||||||
<input type="password" class="form-control" id="line_token" name="line_token"
|
|
||||||
value="{{.notifySettings.LineNotifyToken}}" placeholder="トークンを入力">
|
|
||||||
<div class="form-text">
|
|
||||||
<a href="https://notify-bot.line.me/my/" target="_blank">LINE Notify</a>でトークンを発行
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<hr class="my-3">
|
<hr class="my-3">
|
||||||
<div class="form-check form-switch mb-3">
|
<div class="form-check form-switch mb-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user