-
-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve guest accounts loading, add JSONL support
- Loading branch information
Showing
5 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ nitter | |
/public/css/style.css | ||
/public/md/*.html | ||
nitter.conf | ||
guest_accounts.json* | ||
dump.rdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import jsony | ||
import ../types/guestaccount | ||
from ../../types import GuestAccount | ||
|
||
proc toGuestAccount(account: RawAccount): GuestAccount = | ||
let id = account.oauthToken[0 ..< account.oauthToken.find('-')] | ||
result = GuestAccount( | ||
id: id, | ||
oauthToken: account.oauthToken, | ||
oauthSecret: account.oauthTokenSecret | ||
) | ||
|
||
proc parseGuestAccount*(raw: string): GuestAccount = | ||
let rawAccount = raw.fromJson(RawAccount) | ||
result = rawAccount.toGuestAccount | ||
|
||
proc parseGuestAccounts*(path: string): seq[GuestAccount] = | ||
let rawAccounts = readFile(path).fromJson(seq[RawAccount]) | ||
for account in rawAccounts: | ||
result.add account.toGuestAccount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type | ||
RawAccount* = object | ||
oauthToken*: string | ||
oauthTokenSecret*: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters