diff --git a/epicyon.py b/epicyon.py
index 5b7dc15ee..043c51601 100644
--- a/epicyon.py
+++ b/epicyon.py
@@ -103,6 +103,7 @@ from socnet import instances_graph
from migrate import migrate_accounts
from desktop_client import run_desktop_client
from happening import dav_month_via_server
+from happening import dav_day_via_server
def str2bool(value_str) -> bool:
@@ -192,6 +193,9 @@ parser.add_argument('--year', dest='year', type=int,
parser.add_argument('--month', dest='month', type=int,
default=search_date.month,
help='Month for calendar query')
+parser.add_argument('--day', dest='day', type=int,
+ default=None,
+ help='Day for calendar query')
parser.add_argument('--postsPerSource',
dest='max_newswire_postsPerSource', type=int,
default=4,
@@ -1443,12 +1447,20 @@ if args.dav:
elif args.gnunet:
proxy_type = 'gnunet'
session = create_session(proxy_type)
- result = \
- dav_month_via_server(session, http_prefix,
- args.nickname, args.domain, args.port,
- args.debug,
- args.year, args.month,
- args.password)
+ if args.day:
+ result = \
+ dav_day_via_server(session, http_prefix,
+ args.nickname, args.domain, args.port,
+ args.debug,
+ args.year, args.month, args.day,
+ args.password)
+ else:
+ result = \
+ dav_month_via_server(session, http_prefix,
+ args.nickname, args.domain, args.port,
+ args.debug,
+ args.year, args.month,
+ args.password)
if result:
print(str(result))
sys.exit()
diff --git a/happening.py b/happening.py
index a3d536637..947a993f7 100644
--- a/happening.py
+++ b/happening.py
@@ -1075,9 +1075,9 @@ def dav_report_response(base_dir: str, nickname: str, domain: str,
if query_start_day == query_end_day:
# calendar for one day
search_date = \
- datetime.datetime(year=query_start_year,
- month=query_start_month,
- day=query_start_day)
+ datetime(year=query_start_year,
+ month=query_start_month,
+ day=query_start_day)
ical_events = \
get_todays_events_icalendar(base_dir, nickname, domain,
search_date.year,
@@ -1303,7 +1303,53 @@ def dav_month_via_server(session, http_prefix: str,
' \n' + \
+ '31T235959Z"/>\n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ''
+ result = \
+ get_method("REPORT", xml_str, session, url, params, headers, debug)
+ return result
+
+
+def dav_day_via_server(session, http_prefix: str,
+ nickname: str, domain: str, port: int,
+ debug: bool,
+ year: int, month: int, day: int,
+ password: str) -> str:
+ """Gets the icalendar for a day via caldav
+ """
+ auth_header = create_basic_auth_header(nickname, password)
+
+ headers = {
+ 'host': domain,
+ 'Content-type': 'application/xml',
+ 'Authorization': auth_header
+ }
+ domain_full = get_full_domain(domain, port)
+ params = {}
+ url = http_prefix + '://' + domain_full + '/calendars/' + nickname
+ month_str = str(month)
+ if month < 10:
+ month_str = '0' + month_str
+ day_str = str(day)
+ if day < 10:
+ day_str = '0' + day_str
+ xml_str = \
+ '\n' + \
+ '\n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
' \n' + \
' \n' + \
' \n' + \
diff --git a/tests.py b/tests.py
index 51a04b075..8d958c92d 100644
--- a/tests.py
+++ b/tests.py
@@ -177,6 +177,7 @@ from shares import get_shared_items_catalog_via_server
from blocking import load_cw_lists
from blocking import add_cw_from_lists
from happening import dav_month_via_server
+from happening import dav_day_via_server
TEST_SERVER_GROUP_RUNNING = False
@@ -3176,17 +3177,20 @@ def test_client_to_server(base_dir: str):
if os.path.isfile(os.path.join(alice_inbox_path, name))]) == 0
print('\n\nEVENT: Bob checks his calendar via caldav')
- if os.path.isfile(bob_dir + '/basic_auth_fail.txt'):
- os.remove(bob_dir + '/basic_auth_fail.txt')
result = \
dav_month_via_server(session_bob, http_prefix,
'bob', bob_domain, bob_port, True,
test_date.year, test_date.month,
'bobpass')
print('response: ' + str(result))
- if os.path.isfile(bob_dir + '/basic_auth_fail.txt'):
- with open(bob_dir + '/basic_auth_fail.txt', 'r') as fp_fail:
- print(fp_fail.read())
+ assert 'VCALENDAR' in str(result)
+ assert 'VEVENT' in str(result)
+ result = \
+ dav_day_via_server(session_bob, http_prefix,
+ 'bob', bob_domain, bob_port, True,
+ test_date.year, test_date.month,
+ test_date.day, 'bobpass')
+ print('response: ' + str(result))
assert 'VCALENDAR' in str(result)
assert 'VEVENT' in str(result)