kopia lustrzana https://github.com/snarfed/bridgy-fed
punt on getRepostedBy for now
rodzic
39d5485a52
commit
2bf2a77584
|
@ -1,5 +1,6 @@
|
||||||
"""Unit tests for feed.py."""
|
"""Unit tests for feed.py."""
|
||||||
import copy
|
import copy
|
||||||
|
from unittest import skip
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from granary.tests.test_bluesky import (
|
from granary.tests.test_bluesky import (
|
||||||
|
@ -32,10 +33,10 @@ POST_THREAD_HTML = copy.deepcopy(POST_HTML).replace('</article>', """
|
||||||
<p class="p-content">Uh huh</p>
|
<p class="p-content">Uh huh</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-cite">
|
<div class="u-repost h-cite">
|
||||||
<a class="u-author h-card" href="http://eve.net/">Eve</a>
|
<a class="u-author h-card" href="http://eve.net/">Eve</a>
|
||||||
<p class="p-content">Nuh uh</p>
|
<p class="p-content">This</p>
|
||||||
<a class="u-in-reply-to" href="http://orig/post"></a>
|
<a class="u-repost-of" href="http://orig/post"></a>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
""")
|
""")
|
||||||
|
@ -137,17 +138,27 @@ class XrpcFeedTest(testutil.TestCase):
|
||||||
query_string={'uri': 'http://a/post'})
|
query_string={'uri': 'http://a/post'})
|
||||||
self.assertEqual(400, resp.status_code, resp.get_data(as_text=True))
|
self.assertEqual(400, resp.status_code, resp.get_data(as_text=True))
|
||||||
|
|
||||||
# def test_getRepostedBy(self, mock_get):
|
@skip
|
||||||
# mock_get.return_value = requests_response("""
|
def test_getRepostedBy(self, mock_get):
|
||||||
# <body>
|
mock_get.return_value = requests_response(POST_THREAD_HTML,
|
||||||
# </body>
|
url='http://orig/post')
|
||||||
# """, url='https://foo.com/')
|
got = self.client.get('/xrpc/app.bsky.feed.getRepostedBy',
|
||||||
|
query_string={'uri': 'http://a/post'})
|
||||||
# got = self.client.get('/xrpc/app.bsky.feed.getRepostedBy',
|
self.assertEqual({
|
||||||
# query_string={'actor': 'foo.com'},
|
'uri': 'http://orig/post',
|
||||||
# ).json
|
'repostBy': [{
|
||||||
# self.assertEqual({
|
'$type': 'app.bsky.feed.getRepostedBy#repostedBy',
|
||||||
# }, got)
|
'did': 'did:web:eve.net',
|
||||||
|
'declaration': {
|
||||||
|
'$type': 'app.bsky.system.declRef',
|
||||||
|
'cid': 'TODO',
|
||||||
|
'actorType': 'app.bsky.system.actorUser',
|
||||||
|
},
|
||||||
|
'handle': 'eve.net',
|
||||||
|
'displayName': 'Eve',
|
||||||
|
'indexedAt': '2022-01-02T03:04:05+00:00',
|
||||||
|
}],
|
||||||
|
}, got.json)
|
||||||
|
|
||||||
# def test_getTimeline(self, mock_get):
|
# def test_getTimeline(self, mock_get):
|
||||||
# mock_get.return_value = requests_response("""
|
# mock_get.return_value = requests_response("""
|
||||||
|
@ -156,10 +167,9 @@ class XrpcFeedTest(testutil.TestCase):
|
||||||
# """, url='https://foo.com/')
|
# """, url='https://foo.com/')
|
||||||
|
|
||||||
# got = self.client.get('/xrpc/app.bsky.feed.getTimeline',
|
# got = self.client.get('/xrpc/app.bsky.feed.getTimeline',
|
||||||
# query_string={'actor': 'foo.com'},
|
# query_string={'actor': 'foo.com'})
|
||||||
# ).json
|
|
||||||
# self.assertEqual({
|
# self.assertEqual({
|
||||||
# }, got)
|
# }, got.json)
|
||||||
|
|
||||||
def test_getVotes(self, mock_get):
|
def test_getVotes(self, mock_get):
|
||||||
resp = self.client.get('/xrpc/app.bsky.feed.getVotes',
|
resp = self.client.get('/xrpc/app.bsky.feed.getVotes',
|
||||||
|
|
53
xrpc_feed.py
53
xrpc_feed.py
|
@ -76,17 +76,50 @@ def getPostThread(input, uri=None, depth=None):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@xrpc_server.method('app.bsky.feed.getRepostedBy')
|
# TODO
|
||||||
def getRepostedBy(input, uri=None, cid=None, limit=None, before=None):
|
# what's the mf2 for repost children of an h-entry? u-repost, like u-comment?
|
||||||
"""
|
# nothing about markup on https://indieweb.org/reposts
|
||||||
lexicons/app/bsky/feed/getRepostedBy.json
|
# based on https://indieweb.org/comments-display , it would be u-repost
|
||||||
"""
|
# @xrpc_server.method('app.bsky.feed.getRepostedBy')
|
||||||
|
# def getRepostedBy(input, uri=None, cid=None, limit=None, before=None):
|
||||||
|
# """
|
||||||
|
# lexicons/app/bsky/feed/getRepostedBy.json
|
||||||
|
# """
|
||||||
|
# mf2 = util.fetch_mf2(uri, gateway=True)
|
||||||
|
# logger.info(f'Got mf2: {json.dumps(mf2, indent=2)}')
|
||||||
|
|
||||||
|
# entry = mf2util.find_first_entry(mf2, ['h-entry'])
|
||||||
|
# logger.info(f'Entry: {json.dumps(entry, indent=2)}')
|
||||||
|
# if not entry:
|
||||||
|
# raise ValueError(f"No h-entry on {uri}")
|
||||||
|
|
||||||
|
# obj = microformats2.json_to_object(entry)
|
||||||
|
# logger.info(f'AS1: {json.dumps(obj, indent=2)}')
|
||||||
|
|
||||||
|
# return {
|
||||||
|
# 'uri': 'http://orig/post',
|
||||||
|
# 'repostBy': [{
|
||||||
|
# '$type': 'app.bsky.feed.getRepostedBy#repostedBy',
|
||||||
|
# 'did': 'did:web:eve.net',
|
||||||
|
# 'declaration': {
|
||||||
|
# '$type': 'app.bsky.system.declRef',
|
||||||
|
# 'cid': 'TODO',
|
||||||
|
# 'actorType': 'app.bsky.system.actorUser',
|
||||||
|
# },
|
||||||
|
# 'handle': 'eve.net',
|
||||||
|
# 'displayName': 'Eve',
|
||||||
|
# 'indexedAt': '2022-01-02T03:04:05+00:00',
|
||||||
|
# }],
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
# TODO based on datastore
|
||||||
|
# @xrpc_server.method('app.bsky.feed.getTimeline')
|
||||||
|
# def getTimeline(input):
|
||||||
|
# """
|
||||||
|
# lexicons/app/bsky/feed/getTimeline.json
|
||||||
|
# """
|
||||||
|
|
||||||
@xrpc_server.method('app.bsky.feed.getTimeline')
|
|
||||||
def getTimeline(input):
|
|
||||||
"""
|
|
||||||
lexicons/app/bsky/feed/getTimeline.json
|
|
||||||
"""
|
|
||||||
|
|
||||||
# TODO: use likes as votes?
|
# TODO: use likes as votes?
|
||||||
@xrpc_server.method('app.bsky.feed.getVotes')
|
@xrpc_server.method('app.bsky.feed.getVotes')
|
||||||
|
|
Ładowanie…
Reference in New Issue