~aw/fishbb

0fba4deae06b502a64249e560602d9ba14d030f9 — alex wennerberg 2 months ago e4509db
skeleton for notifications
3 files changed, 24 insertions(+), 0 deletions(-)

A notifications.go
M schema.sql
M views/header.html
A notifications.go => notifications.go +20 -0
@@ 0,0 1,20 @@
package main

import "time"

type Notification struct {
	ID      int
	Message string // markdown
	Created time.Time
}

//  Don't keep notifications beyond this
const maxNotifications = 128

func getNotifications(uid int) ([]Notification, error) {
	return nil, nil
}

func storeNotification(uid int, message string) ([]Notification, error) {
	return nil, nil
}

M schema.sql => schema.sql +3 -0
@@ 42,6 42,7 @@ create table users (
  about text not null default 'someone',
  website text not null default '',
  created datetime default current_timestamp
  last_notification_view datetime,
);

create table auth (


@@ 63,9 64,11 @@ create index idxposts_threadid on posts(threadid);
-- create table invitations ( );
-- create table reports
create table notifications (
  id integer primary key,
  type text not null,
  message text, -- markdown
  created datetime default current_timestamp,
  foreign key (userid) references users(id)
);

pragma journal_mode = wal;

M views/header.html => views/header.html +1 -0
@@ 26,6 26,7 @@
      {{ else }}
	  Hello, <a href="/me">{{.User.Username}}</a>.
	  {{ if .User.Role.ModLevel }}<a href="/control">control</a>{{ end }}
	  <a href="/notifications">✉️</a>
	  <form style="display:inline" action="/logout" method="POST"><button class="link-button">Logout</button>
	<input type="hidden" name="CSRF" value="{{.CSRFToken}}">
	  </form>