mirror of
https://github.com/andrigamerita/simpkey
synced 2025-06-05 22:09:26 +02:00
wip
This commit is contained in:
@ -29,6 +29,6 @@ export const render = views(__dirname + '/views', {
|
||||
}
|
||||
if (note.localOnly) icon += '☣';
|
||||
return icon;
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
@ -23,9 +23,14 @@ async function timeline(ctx: Context, host: string, endpoint: string, timelineNa
|
||||
const user = await i(host, token);
|
||||
const notes = await api<Note[]>(host, endpoint, { i: token });
|
||||
|
||||
const myself = await i(host, token);
|
||||
await ctx.render('timeline', {
|
||||
title: timelineName + ' - Simpkey',
|
||||
user, notes, timelineName
|
||||
user,
|
||||
notes,
|
||||
timelineName,
|
||||
canRenote: (note: Note) => note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home',
|
||||
canReact: (note: Note) => note.userId !== myself.id,
|
||||
});
|
||||
}
|
||||
|
||||
@ -97,8 +102,13 @@ router.get('/notifications', async ctx => {
|
||||
return;
|
||||
}
|
||||
|
||||
const myself = await i(host, token);
|
||||
const notifications = await api<any>(host, 'i/notifications', { i: token });
|
||||
await ctx.render('notifications', { notifications });
|
||||
await ctx.render('notifications', {
|
||||
notifications,
|
||||
canRenote: (note: Note) => note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home',
|
||||
canReact: (note: Note) => note.userId !== myself.id,
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -111,8 +121,12 @@ router.get('/renote/:noteId', async ctx => {
|
||||
}
|
||||
|
||||
try {
|
||||
const myself = await i(host, token);
|
||||
const note = await notesShow(host, ctx.params.noteId);
|
||||
await ctx.render('renote', { note });
|
||||
await ctx.render('renote', {
|
||||
note,
|
||||
canRenote: note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home'
|
||||
});
|
||||
} catch(e) {
|
||||
await die(ctx, e.message);
|
||||
}
|
||||
@ -145,16 +159,20 @@ router.get('/react/:noteId', async ctx => {
|
||||
try {
|
||||
const note = await notesShow(host, ctx.params.noteId);
|
||||
const myself = await i(host, token);
|
||||
await ctx.render('react', { note, reactions: myself.clientData?.reactions });
|
||||
await ctx.render('react', {
|
||||
note,
|
||||
reactions: myself.clientData?.reactions,
|
||||
canReact: note.userId !== myself.id && !note.myReaction
|
||||
});
|
||||
} catch(e) {
|
||||
await die(ctx, e.message);
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/@:acct', async ctx => {
|
||||
const i = ctx.cookies.get('i');
|
||||
const token = ctx.cookies.get('i');
|
||||
const host = ctx.cookies.get('host');
|
||||
if (!i || !host) {
|
||||
if (!token || !host) {
|
||||
await die(ctx, 'ログインしてください');
|
||||
return;
|
||||
}
|
||||
@ -162,10 +180,16 @@ router.get('/@:acct', async ctx => {
|
||||
const acct = ctx.params.acct.split('@');
|
||||
const username = acct[0];
|
||||
const remoteHost = acct[1];
|
||||
const myself = await i(host, token);
|
||||
|
||||
const user = await usersShowByName(host, username, remoteHost);
|
||||
const notes = await api<Note[]>(host, 'users/notes', { i, userId: user.id });
|
||||
await ctx.render('user', { user, notes });
|
||||
const notes = await api<Note[]>(host, 'users/notes', { i: token, userId: user.id });
|
||||
await ctx.render('user', {
|
||||
user,
|
||||
notes,
|
||||
canRenote: (note: Note) => note.userId === myself.id || note.visibility === 'public' || note.visibility === 'home',
|
||||
canReact: (note: Note) => note.userId !== myself.id,
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/', async ctx => {
|
||||
|
@ -54,9 +54,12 @@ mixin note(note)
|
||||
footer
|
||||
|[
|
||||
a(href="/reply/" + note.id) リプライ !{note.repliesCount}
|
||||
|] [
|
||||
|]
|
||||
if canRenote && canRenote(note)
|
||||
|[
|
||||
a(href="/renote/" + note.id) リノート !{note.renoteCount}
|
||||
|]
|
||||
if canReact && canReact(note)
|
||||
if !note.myReaction
|
||||
| [
|
||||
a(href="/react/" + note.id) リアクション
|
||||
|
@ -1,6 +1,7 @@
|
||||
extends _base
|
||||
|
||||
block content
|
||||
if canReact
|
||||
h2 このノートにリアクションを押しますか?
|
||||
+sub-note(note)
|
||||
form(action="/action/react", method="post")
|
||||
@ -14,3 +15,6 @@ block content
|
||||
input(type="hidden", name="noteId", value=note.id)
|
||||
|
||||
button(type="submit") リアクションを押す
|
||||
else
|
||||
h2 このノートにはリアクションできません
|
||||
+sub-note(note)
|
@ -1,7 +1,11 @@
|
||||
extends _base
|
||||
|
||||
block content
|
||||
if canRenote
|
||||
h2 このノートをリノートしますか?
|
||||
+sub-note(note)
|
||||
+post-form('/action/create-note', "コメント(省略可能)", "リノート")
|
||||
input(type="hidden", name="renoteId", value=note.id)
|
||||
else
|
||||
h2 このノートはリノートできません
|
||||
+sub-note(note)
|
Reference in New Issue
Block a user