tangled
alpha
login
or
join now
yoten.app
/
yoten
17
fork
atom
Yōten: A social tracker for your language learning journey built on the atproto.
17
fork
atom
overview
issues
pulls
pipelines
refactor: renames + deletion of unused code
brookjeynes.dev
5 months ago
825b488f
00a5366e
verified
This commit was signed with the committer's
known signature
.
brookjeynes.dev
SSH Key Fingerprint:
SHA256:N3n3PCBSiXfS6EHlmGdx+LMEruJMj6FS2hqaXyfsw0s=
+15
-28
4 changed files
expand all
collapse all
unified
split
internal
consumer
ingester.go
server
handlers
comment.go
oauth
handler
handler.go
views
partials
discussion.templ
+6
-6
internal/consumer/ingester.go
···
121
122
ddb, ok := i.Db.Execer.(*db.DB)
123
if !ok {
124
-
return fmt.Errorf("failed to index profile record: %w", err)
125
}
126
127
tx, err := ddb.Begin()
···
336
337
ddb, ok := i.Db.Execer.(*db.DB)
338
if !ok {
339
-
return fmt.Errorf("failed to index activity def record: %w", err)
340
}
341
342
tx, err := ddb.Begin()
···
377
378
ddb, ok := i.Db.Execer.(*db.DB)
379
if !ok {
380
-
return fmt.Errorf("failed to index activity def record: %w", err)
381
}
382
383
tx, err := ddb.Begin()
···
427
428
ddb, ok := i.Db.Execer.(*db.DB)
429
if !ok {
430
-
return fmt.Errorf("failed to index reaction record: %w", err)
431
}
432
433
tx, err := ddb.Begin()
···
514
515
ddb, ok := i.Db.Execer.(*db.DB)
516
if !ok {
517
-
return fmt.Errorf("failed to index resource record: %w", err)
518
}
519
520
tx, err := ddb.Begin()
···
595
596
ddb, ok := i.Db.Execer.(*db.DB)
597
if !ok {
598
-
return fmt.Errorf("failed to index resource record: %w", err)
599
}
600
601
tx, err := ddb.Begin()
···
121
122
ddb, ok := i.Db.Execer.(*db.DB)
123
if !ok {
124
+
return fmt.Errorf("failed to index profile record: ddb not valid")
125
}
126
127
tx, err := ddb.Begin()
···
336
337
ddb, ok := i.Db.Execer.(*db.DB)
338
if !ok {
339
+
return fmt.Errorf("failed to index activity def record: ddb not valid")
340
}
341
342
tx, err := ddb.Begin()
···
377
378
ddb, ok := i.Db.Execer.(*db.DB)
379
if !ok {
380
+
return fmt.Errorf("failed to index activity def record: ddb not valid")
381
}
382
383
tx, err := ddb.Begin()
···
427
428
ddb, ok := i.Db.Execer.(*db.DB)
429
if !ok {
430
+
return fmt.Errorf("failed to index reaction record: ddb not valid")
431
}
432
433
tx, err := ddb.Begin()
···
514
515
ddb, ok := i.Db.Execer.(*db.DB)
516
if !ok {
517
+
return fmt.Errorf("failed to index resource record: ddb not valid")
518
}
519
520
tx, err := ddb.Begin()
···
595
596
ddb, ok := i.Db.Execer.(*db.DB)
597
if !ok {
598
+
return fmt.Errorf("failed to index resource record: ddb not valid")
599
}
600
601
tx, err := ddb.Begin()
+6
-18
internal/server/handlers/comment.go
···
75
CreatedAt: time.Now(),
76
}
77
78
-
newCommentRecord := yoten.FeedComment{
79
-
LexiconTypeID: yoten.FeedCommentNSID,
80
-
Body: newComment.Body,
81
-
Subject: newComment.StudySessionUri.String(),
82
-
CreatedAt: newComment.CreatedAt.Format(time.RFC3339),
83
-
}
84
-
85
_, err = client.RepoPutRecord(r.Context(), &comatproto.RepoPutRecord_Input{
86
Collection: yoten.FeedCommentNSID,
87
Repo: newComment.Did,
88
Rkey: newComment.Rkey,
89
Record: &lexutil.LexiconTypeDecoder{
90
-
Val: &newCommentRecord,
0
0
0
0
0
91
},
92
})
93
if err != nil {
94
log.Println("failed to create comment record:", err)
95
htmx.HxError(w, http.StatusInternalServerError, "Failed to create comment, try again later.")
96
return
97
-
}
98
-
99
-
err = SavePendingCreate(h, w, r, PendingCommentCreation, newComment)
100
-
if err != nil {
101
-
log.Printf("failed to save yoten-session to add pending comment creation: %v", err)
102
}
103
104
if !h.Config.Core.Dev {
···
173
log.Println("failed to delete comment from PDS:", err)
174
htmx.HxError(w, http.StatusInternalServerError, "Failed to delete comment, try again later.")
175
return
176
-
}
177
-
178
-
err = SavePendingDelete(h, w, r, PendingCommentDeletion, comment)
179
-
if err != nil {
180
-
log.Printf("failed to save yoten-session to add pending comment deletion: %v", err)
181
}
182
183
if !h.Config.Core.Dev {
···
75
CreatedAt: time.Now(),
76
}
77
0
0
0
0
0
0
0
78
_, err = client.RepoPutRecord(r.Context(), &comatproto.RepoPutRecord_Input{
79
Collection: yoten.FeedCommentNSID,
80
Repo: newComment.Did,
81
Rkey: newComment.Rkey,
82
Record: &lexutil.LexiconTypeDecoder{
83
+
Val: &yoten.FeedComment{
84
+
LexiconTypeID: yoten.FeedCommentNSID,
85
+
Body: newComment.Body,
86
+
Subject: newComment.StudySessionUri.String(),
87
+
CreatedAt: newComment.CreatedAt.Format(time.RFC3339),
88
+
},
89
},
90
})
91
if err != nil {
92
log.Println("failed to create comment record:", err)
93
htmx.HxError(w, http.StatusInternalServerError, "Failed to create comment, try again later.")
94
return
0
0
0
0
0
95
}
96
97
if !h.Config.Core.Dev {
···
166
log.Println("failed to delete comment from PDS:", err)
167
htmx.HxError(w, http.StatusInternalServerError, "Failed to delete comment, try again later.")
168
return
0
0
0
0
0
169
}
170
171
if !h.Config.Core.Dev {
+3
-3
internal/server/oauth/handler/handler.go
···
263
}
264
}()
265
266
-
error := r.FormValue("error")
267
errorDescription := r.FormValue("error_description")
268
-
if error != "" || errorDescription != "" {
269
-
log.Printf("oauth callback error: %s, %s", error, errorDescription)
270
htmx.HxError(w, http.StatusUnauthorized, "Failed to authenticate. Try again later.")
271
return
272
}
···
263
}
264
}()
265
266
+
callbackErr := r.FormValue("error")
267
errorDescription := r.FormValue("error_description")
268
+
if callbackErr != "" || errorDescription != "" {
269
+
log.Printf("oauth callback error: %s, %s", callbackErr, errorDescription)
270
htmx.HxError(w, http.StatusUnauthorized, "Failed to authenticate. Try again later.")
271
return
272
}
-1
internal/server/views/partials/discussion.templ
···
13
hx-disabled-elt="#post-comment-button"
14
@htmx:after-request="text = ''"
15
x-data="{ text: '' }"
16
-
x-init="text = $el.querySelector('textarea').value"
17
>
18
<input type="hidden" name="study_session_uri" value={ params.StudySessionUri }/>
19
<div class="mt-2">
···
13
hx-disabled-elt="#post-comment-button"
14
@htmx:after-request="text = ''"
15
x-data="{ text: '' }"
0
16
>
17
<input type="hidden" name="study_session_uri" value={ params.StudySessionUri }/>
18
<div class="mt-2">