Skip to content

Commit

Permalink
feat: internal comm
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Mar 8, 2024
1 parent f07b5cc commit 8f61992
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 3 deletions.
50 changes: 49 additions & 1 deletion web/intcomm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ async function requestIncreasePublishingDailyLimit(objId) {
increment: {
ce_integer: inc,
},
limit: {
ce_integer: parseInt(document.getElementById("limit").value),
},
action: {
ce_string: "request",
},
object: {
ce_string: `publishing daily limit for ${objId}`,
ce_string: `daily publications for ${objId}`,
},
subject: {
ce_string: userIdCurrent,
Expand All @@ -47,6 +50,51 @@ async function requestIncreasePublishingDailyLimit(objId) {
}
}

async function requestIncreaseSubscriptionsLimit(userId) {
const msg = "Request to increase the subscriptions limit\nPlease enter the number to add:"
const input = prompt(msg, "1");
if (input) {
let inc = 0;
try {
inc = parseInt(input);
} catch (e) {
console.log(e);
}
if (inc > 0) {
const payload = {
id: uuidv4(),
specVersion: "1.0",
source: "awakari.com",
type: "com.github.awakari.webapp",
attributes: {
increment: {
ce_integer: inc,
},
limit: {
ce_integer: parseInt(document.getElementById("limit").value),
},
action: {
ce_string: "request",
},
object: {
ce_string: "subscriptions",
},
subject: {
ce_string: userId,
},
},
text_data: `User ${userId} requests to increase the subscriptions limit by ${inc}`,
}
if (await submitMessageInternal(payload, userId)) {
document.getElementById("request-increase-success-dialog").style.display = "block";
document.getElementById("request-id").innerText = payload.id;
}
} else {
alert(`Invalid increment value: ${inc}\nShould be a positive integer.`);
}
}
}

async function reportPublishingSourceInappropriate(srcAddr) {
const userIdCurrent = localStorage.getItem(keyUserId);
const reason = prompt(`Please specify the reason why do you think the source is inappropriate.\nSource: ${srcAddr}`)
Expand Down
2 changes: 1 addition & 1 deletion web/pub-src-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@

<div id="report-success-dialog"
class="border border-gray-500 p-1 rounded-md shadow-lg bg-white dark:bg-gray-900 flex flex-col space-y-1"
style="position: absolute; display: none">
style="position: absolute; display: none; margin-left: -1px">
<div class="flex w-full">
<div class="w-full">
<span class="text-lg">
Expand Down
3 changes: 3 additions & 0 deletions web/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ const templateEvent = (txt, time, srcUrl, link) => `
</span>
</p>
</a>
<button id="button_src_report" type="button" class="flex report justify-center text-center">
<span class="pt-1">⚠</span>
</button>
</div>
`

Expand Down
40 changes: 39 additions & 1 deletion web/sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<link href="style.css" rel="stylesheet">

<script src="login.js"></script>
<script src="intcomm.js"></script>
<script src="sub.js"></script>
<script>
navigator.serviceWorker.register("sw.js");
Expand Down Expand Up @@ -59,9 +60,46 @@
<div class="pt-1 w-28 sm:w-10">Limit:</div>
<div class="pt-1 w-12 sm:w-8" id="limit"></div>
<div class="ml-2">
<button type="button" disabled="disabled" class="text-blue-500 border border-blue-500 w-[100px] h-6 hover:bg-blue-200 dark:hover:bg-blue-900 static px-2">

<button type="button"
onclick="requestIncreaseSubscriptionsLimit(localStorage.getItem(keyUserId))"
class="text-blue-500 border border-blue-500 w-[100px] h-6 hover:bg-blue-200 dark:hover:bg-blue-900 static px-2">
+ Increase
</button>

<div id="request-increase-success-dialog"
class="border border-gray-500 p-1 rounded-md shadow-lg bg-white dark:bg-gray-900 flex flex-col space-y-1"
style="position: absolute; margin-left: -185px; display: none">
<div class="flex w-full">
<div class="w-full">
<span class="text-lg">
Request submitted.
</span>
</div>
<button type="button"
class="w-6 h-6"
onclick="document.getElementById('request-increase-success-dialog').style.display = 'none'">
</button>
</div>
<p>
Request Id: <span id="request-id"></span>
</p>
<p>
We review the request as soon as possible and update.
</p>
<p>
Please consider to help us to provide the service:
</p>
<div class="flex justify-center">
<button type="button"
onclick="window.open('https://t.me/donateawk/14', '_blank')"
class="flex justify-center text-center w-25 h-6">
<span class="pt-1 px-2">&#10697; Donate</span>
</button>
</div>
</div>

</div>
</div>
</div>
Expand Down

0 comments on commit 8f61992

Please sign in to comment.