forked from retoor/devplacepy
feat: add telegram notification channel with outbox service and per-user preferences
Extend the notification system with a third channel (telegram) alongside existing in_app and push channels. Add `telegram_enabled` column to `notification_preferences` table, update `NOTIFICATION_CHANNELS` and `_NOTIFICATION_CHANNEL_COLUMNS` mappings, and set telegram default to off (`_NOTIFICATION_CHANNEL_DEFAULTS`). Create `telegram_outbox` table with columns for uid, user_uid, chat_id, text, status, attempts, created_at, and sent_at, plus an index on status/id for efficient polling. Register `TelegramOutboxService` in the service manager lifecycle. Update API documentation strings to describe the new channel and its pairing requirement. Extend admin notification defaults view to include telegram column. Pass `notif_telegram_paired` flag to profile template based on `telegram_store.is_paired()` check. Update `NotificationPrefForm` and `NotificationDefaultForm` model literals to accept "telegram" as a valid channel value.
This commit is contained in:
@@ -250,7 +250,7 @@
|
||||
<p class="customization-hint">Runs only when your text contains an inline `@ai instruction` directive: it executes that instruction and removes the `@ai` marker, using your API key. Applies to posts, comments, projects, gists, direct messages and your bio. Code and source files are never touched.</p>
|
||||
</div>
|
||||
|
||||
<div class="customization-card" data-telegram-pairing data-username="{{ profile_user['username'] }}">
|
||||
<div class="customization-card" id="telegram-pairing" data-telegram-pairing data-username="{{ profile_user['username'] }}">
|
||||
<div class="customization-head">
|
||||
<span class="customization-title">Telegram</span>
|
||||
</div>
|
||||
@@ -468,16 +468,16 @@
|
||||
{% endfor %}
|
||||
</details>
|
||||
|
||||
<div class="profile-tabs" data-profile-tabs>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=posts" class="profile-tab {% if current_tab == 'posts' %}active{% endif %}" data-menu-icon="📝" data-menu-label="Posts"><span class="icon">📝</span> Posts</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=projects" class="profile-tab {% if current_tab == 'projects' %}active{% endif %}" data-menu-icon="🚀" data-menu-label="Projects"><span class="icon">🚀</span> Projects</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=gists" class="profile-tab {% if current_tab == 'gists' %}active{% endif %}" data-menu-icon="📝" data-menu-label="Gists"><span class="icon">📝</span> Gists</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=media" class="profile-tab {% if current_tab == 'media' %}active{% endif %}" data-menu-icon="🖼️" data-menu-label="Media"><span class="icon">🖼️</span> Media</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=activity" class="profile-tab {% if current_tab == 'activity' %}active{% endif %}" data-menu-icon="📊" data-menu-label="Activity"><span class="icon">📊</span> Activity</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=followers" class="profile-tab {% if current_tab == 'followers' %}active{% endif %}" data-menu-icon="👥" data-menu-label="Followers ({{ followers_count }})"><span class="icon">👥</span> Followers ({{ followers_count }})</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=following" class="profile-tab {% if current_tab == 'following' %}active{% endif %}" data-menu-icon="👤" data-menu-label="Following ({{ following_count }})"><span class="icon">👤</span> Following ({{ following_count }})</a>
|
||||
<div class="profile-tabs" id="profile-tabs" data-profile-tabs>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=posts#profile-tabs" class="profile-tab {% if current_tab == 'posts' %}active{% endif %}" data-menu-icon="📝" data-menu-label="Posts"><span class="icon">📝</span> Posts</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=projects#profile-tabs" class="profile-tab {% if current_tab == 'projects' %}active{% endif %}" data-menu-icon="🚀" data-menu-label="Projects"><span class="icon">🚀</span> Projects</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=gists#profile-tabs" class="profile-tab {% if current_tab == 'gists' %}active{% endif %}" data-menu-icon="📝" data-menu-label="Gists"><span class="icon">📝</span> Gists</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=media#profile-tabs" class="profile-tab {% if current_tab == 'media' %}active{% endif %}" data-menu-icon="🖼️" data-menu-label="Media"><span class="icon">🖼️</span> Media</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=activity#profile-tabs" class="profile-tab {% if current_tab == 'activity' %}active{% endif %}" data-menu-icon="📊" data-menu-label="Activity"><span class="icon">📊</span> Activity</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=followers#profile-tabs" class="profile-tab {% if current_tab == 'followers' %}active{% endif %}" data-menu-icon="👥" data-menu-label="Followers ({{ followers_count }})"><span class="icon">👥</span> Followers ({{ followers_count }})</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=following#profile-tabs" class="profile-tab {% if current_tab == 'following' %}active{% endif %}" data-menu-icon="👤" data-menu-label="Following ({{ following_count }})"><span class="icon">👤</span> Following ({{ following_count }})</a>
|
||||
{% if is_owner or viewer_is_admin %}
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=notifications" class="profile-tab {% if current_tab == 'notifications' %}active{% endif %}" data-menu-icon="🔔" data-menu-label="Notifications"><span class="icon">🔔</span> Notifications</a>
|
||||
<a href="/profile/{{ profile_user['username'] }}?tab=notifications#profile-tabs" class="profile-tab {% if current_tab == 'notifications' %}active{% endif %}" data-menu-icon="🔔" data-menu-label="Notifications"><span class="icon">🔔</span> Notifications</a>
|
||||
{% endif %}
|
||||
<button type="button" class="profile-tab profile-tabs-more" aria-haspopup="menu" aria-label="More tabs" hidden><span class="icon">⋯</span> More</button>
|
||||
</div>
|
||||
@@ -540,6 +540,9 @@
|
||||
{% set pagination_query = "tab=media&" %}
|
||||
{% include "_pagination.html" %}
|
||||
{% elif current_tab == 'followers' or current_tab == 'following' %}
|
||||
{% if people %}
|
||||
<div class="profile-panel">
|
||||
{% endif %}
|
||||
{% for person in people %}
|
||||
<div class="follow-row">
|
||||
<a href="/profile/{{ person['username'] }}" class="follow-user">
|
||||
@@ -564,6 +567,9 @@
|
||||
{% else %}
|
||||
<div class="empty-state">{% if current_tab == 'followers' %}No followers yet.{% else %}Not following anyone yet.{% endif %}</div>
|
||||
{% endfor %}
|
||||
{% if people %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if follow_pagination and follow_pagination.total_pages > 1 %}
|
||||
<div class="follow-pagination">
|
||||
{% if follow_pagination.has_prev %}<a class="btn btn-ghost btn-sm" href="/profile/{{ profile_user['username'] }}?tab={{ current_tab }}&page={{ follow_pagination.prev_page }}">Previous</a>{% endif %}
|
||||
@@ -573,17 +579,20 @@
|
||||
{% endif %}
|
||||
{% elif current_tab == 'notifications' %}
|
||||
{% if is_owner or viewer_is_admin %}
|
||||
<div class="notif-prefs" data-notif-prefs data-username="{{ profile_user['username'] }}">
|
||||
<div class="notif-prefs profile-panel" data-notif-prefs data-username="{{ profile_user['username'] }}">
|
||||
<div class="notif-prefs-intro">
|
||||
{% if not is_owner %}<p class="notif-prefs-admin">Editing notification settings for <strong>{{ profile_user['username'] }}</strong>.</p>{% endif %}
|
||||
<p>Choose how you want to be notified for each event. <strong>In-app</strong> shows the notification on DevPlace; <strong>Push</strong> sends it to your subscribed devices.</p>
|
||||
<p>Choose how you want to be notified for each event. <strong>In-app</strong> shows the notification on DevPlace; <strong>Push</strong> sends it to your subscribed devices; <strong>Telegram</strong> delivers it to your paired Telegram chat.</p>
|
||||
{% if not notif_telegram_paired %}<p class="notif-prefs-hint">{% if is_owner %}Connect Telegram from the <a href="#telegram-pairing">Telegram panel</a> to enable Telegram notifications.{% else %}This user has not connected Telegram, so Telegram notifications cannot be delivered yet.{% endif %}</p>{% endif %}
|
||||
</div>
|
||||
<div class="notif-prefs-scroll">
|
||||
<table class="notif-prefs-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Notification</th>
|
||||
<th class="notif-prefs-col">In-app</th>
|
||||
<th class="notif-prefs-col">Push</th>
|
||||
<th class="notif-prefs-col">Telegram</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -605,10 +614,17 @@
|
||||
<span class="notif-switch-track"></span>
|
||||
</label>
|
||||
</td>
|
||||
<td class="notif-prefs-col">
|
||||
<label class="notif-switch{% if not notif_telegram_paired %} notif-switch-disabled{% endif %}">
|
||||
<input type="checkbox" data-notif-toggle data-type="{{ pref.key }}" data-channel="telegram" aria-label="Telegram notifications for {{ pref.label }}" {% if pref.telegram %}checked{% endif %} {% if not notif_telegram_paired %}disabled{% endif %}>
|
||||
<span class="notif-switch-track"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="notif-prefs-actions">
|
||||
<button type="button" class="btn btn-ghost btn-sm" data-notif-reset>Reset to defaults</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user