Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Before the catch-all below, and a sub-path of it so `{filter}` cannot
// swallow it either way
['name' => 'APIv2#getHistogram', 'url' => '/api/v2/activity/{filter}/histogram', 'verb' => 'GET'],
['name' => 'APIv2#getActors', 'url' => '/api/v2/activity/{filter}/actors', 'verb' => 'GET'],
['name' => 'APIv2#getFilter', 'url' => '/api/v2/activity/{filter}', 'verb' => 'GET'],
],
'routes' => [
Expand Down
50 changes: 50 additions & 0 deletions docs/endpoint-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,53 @@ timestamp range, which is exactly the `activity_user_time` index. Bucketing into
days happens in PHP rather than in SQL: grouping by day needs integer division or
a modulo, neither of which `IQueryBuilder` can express, and a raw expression
would have to be written four different ways for the databases this app supports.

# Stream accounts

`GET /ocs/v2.php/apps/activity/api/v2/activity/{filter}/actors`

The accounts that authored activities in the stream, for the "filter by account"
control. Derived from the stream itself rather than from the instance's account
list, so it only ever names accounts the caller already sees activities from and
picking one always yields results.

Name | Type | Description
---|---|---
`object_type` / `object_id` | (Optional) | As on the stream endpoint, and only together

Deliberately takes no `search`, `from`/`to` or `actor`. This is the list a
restriction is picked *from*, so narrowing the stream must not narrow it — a
list that shrank to the accounts left in the current result would only be able
to offer what is already on screen. The filter and the object restriction are
honoured, because those select a different stream rather than narrow this one.

At most 100 accounts are returned, ordered by account name.

## Response

```json
[
{ "id": "alice", "displayName": "Alice Cooper" },
{ "id": "bob", "displayName": "Bob" }
]
```

Name | Description
---|---
`id` | The account name, to be passed back as the stream's `actor` parameter
`displayName` | Human readable name, falling back to the account name for deleted and non-local accounts, whose activities stay in the stream and stay filterable

## HTTP Status

Status Code | Description
---|---
`200 OK` | The accounts
`403 Forbidden` | The user is not logged in
`404 Not Found` | The filter is unknown

## Cost

One indexed column, restricted to a single `affecteduser` and read in account
name order, which is the `activity_filter_by` (affecteduser, user, timestamp)
index. The result cap is applied in SQL, so the database stops reading as soon
as it is met.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".download-summary[data-v-81e4514f]{display:flex;align-items:flex-start;padding:8px 0;margin-bottom:calc(var(--default-grid-baseline) * 2);color:var(--color-text-maxcontrast)}.download-summary__icon[data-v-81e4514f]{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:20px;height:20px;margin-top:2px;opacity:.5}.download-summary__text[data-v-81e4514f]{padding:0 5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.activity[data-v-242e244d]{display:flex;flex-direction:column;overflow:hidden;height:100%}.activity__actions[data-v-242e244d]{display:flex;flex-direction:column;width:100%}.activity__list[data-v-242e244d]{flex-grow:1;overflow:scroll}.activity__load-more[data-v-242e244d]{display:flex;justify-content:center;padding-block:calc(var(--default-grid-baseline) * 2)}.activity__empty-content[data-v-242e244d]{height:100%}[data-v-242e244d] .empty-content__icon span{background-size:64px;width:64px;height:64px}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
import{l as R}from"./lightning-bolt-CVnodBao.chunk.mjs";import{b as M,m as S,h as P,o as D,N as V}from"./NcCheckboxRadioSwitch-BVTMQSAg-BT9wuQMx.chunk.mjs";import{d as C,x as q,B,y as T,a,c as o,j as H,W as p,J as f,m as n,e as k,f as c,t as I,E as y,l as W,b as d,g as u,F as g,K as G,a1 as F,h as O,n as U}from"./translation-DoG5ZELJ-eekoBSws.chunk.mjs";import{a as N}from"./index-BrNGPgve.chunk.mjs";import{j as z,f as J,A as K}from"./ActivityComponent.vue_vue_type_script_setup_true_lang-DX_K5EUD.chunk.mjs";import{l as w}from"./logger-CXg3FpL2.chunk.mjs";import{g as Z,a as $,b as Q}from"./api-fwrRGLr6.chunk.mjs";var b;(function(t){t[t.User=0]="User",t[t.Group=1]="Group",t[t.Link=3]="Link",t[t.Email=4]="Email",t[t.Remote=6]="Remote",t[t.Team=7]="Team",t[t.Guest=8]="Guest",t[t.RemoteGroup=9]="RemoteGroup",t[t.Room=10]="Room",t[t.Deck=12]="Deck",t[t.FederatedGroup=14]="FederatedGroup",t[t.ScienceMesh=15]="ScienceMesh"})(b||(b={}));const X=C({__name:"ActivitySidebarPlugin",props:{plugin:{},node:{}},emits:["reloadActivities"],setup(t,{emit:e}){const i=t,s=e,r=H();return q(()=>i.plugin.mount(r.value,{node:i.node,context:B()?.proxy??void 0,reload:()=>s("reloadActivities")})),T(()=>i.plugin.unmount()),(m,l)=>(a(),o("div",{ref_key:"attachTarget",ref:r},null,512))}}),Y='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-download-circle" viewBox="0 0 24 24"><path d="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M8 17H16V15H8V17M16 10H13.5V6H10.5V10H8L12 14L16 10Z" /></svg>',tt=C({name:"DownloadSummary",components:{NcIconSvgWrapper:M},props:{fileId:{type:Number,required:!0}},data(){return{totalCount:0,monthlyCount:0,downloadSVG:Y}},computed:{summaryText(){return this.monthlyCount>0&&this.monthlyCount<this.totalCount?p("activity","Downloaded %n time (%s in the last 30 days)","Downloaded %n times (%s in the last 30 days)",this.totalCount,[String(this.monthlyCount)]):p("activity","Downloaded %n time","Downloaded %n times",this.totalCount)}},watch:{fileId:{immediate:!0,handler(){this.fetchCounts()}}},methods:{async fetchCounts(){if(this.fileId){this.totalCount=0,this.monthlyCount=0;try{const t=await S.get(N("apps/activity/api/v2/activity/downloads/count"),{params:{format:"json",object_type:"files",object_id:this.fileId}});this.totalCount=t.data.ocs.data.total,this.monthlyCount=t.data.ocs.data.last30d}catch(t){w.error("Failed to fetch download counts",{error:t})}}},t:f,n:p}}),it={key:0,class:"download-summary"},et={class:"download-summary__icon"},at={class:"download-summary__text"};function st(t,e,i,s,r,m){const l=n("NcIconSvgWrapper");return t.totalCount>0?(a(),o("div",it,[k("span",et,[c(l,{svg:t.downloadSVG,size:20},null,8,["svg"])]),k("span",at,I(t.summaryText),1)])):y("",!0)}const ot=P(tt,[["render",st],["__scopeId","data-v-81e4514f"]]),nt=50,rt=C({name:"ActivityTab",components:{ActivityComponent:J,DownloadSummary:ot,NcButton:V,NcEmptyContent:z,NcIconSvgWrapper:M,NcLoadingIcon:D,ActivitySidebarPlugin:X},props:{node:{type:Object,required:!0},folder:{type:Object,required:!1,default:void 0},view:{type:Object,required:!1,default:void 0}},expose:["update"],data(){return{error:"",loading:!0,loadingMore:!1,activities:[],lightningBoltSVG:R,sidebarPlugins:[],requestController:null,realActivities:[],otherEntries:[],lastGiven:void 0,hasMore:!1}},computed:{hasPublicLink(){return Object.values(this.node?.attributes?.["share-types"]??{}).flat().includes(b.Link)}},watch:{node:{immediate:!0,async handler(){await this.update()}}},beforeUnmount(){this.requestController?.abort()},methods:{async update(){this.sidebarPlugins=[];const t=Q();t.length>0&&W(()=>{this.sidebarPlugins=t}),this.resetState(),await this.getActivities()},async getActivities(){await this.fetchPage(!0)},async loadMoreActivities(){await this.fetchPage(!1)},async fetchPage(t){this.requestController?.abort();const e=new AbortController;this.requestController=e;const{signal:i}=e;try{t?this.loading=!0:this.loadingMore=!0;const s=await this.loadRealActivities(i,t?void 0:this.lastGiven),r=this.processActivities(s.activities),m=t?await $({node:this.node}):this.otherEntries;if(i.aborted)return;this.realActivities=t?r:[...this.realActivities,...r],this.otherEntries=m,(t||s.lastGiven!==void 0)&&(this.lastGiven=s.lastGiven),this.hasMore=s.hasMore,this.activities=[...this.realActivities,...this.otherEntries].sort((l,h)=>h.timestamp-l.timestamp)}catch(s){if(i.aborted)return;this.error=f("activity","Unable to load the activity list"),w.error("Error loading the activity list",{error:s})}finally{i.aborted||(this.loading=!1,this.loadingMore=!1)}},resetState(){this.loading=!0,this.loadingMore=!1,this.error="",this.activities=[],this.realActivities=[],this.otherEntries=[],this.lastGiven=void 0,this.hasMore=!1},async loadRealActivities(t,e){try{const i=await S.get(N("apps/activity/api/v2/activity/filter"),{signal:t,params:{format:"json",object_type:"files",object_id:this.node.fileid,limit:nt,...e===void 0?{}:{since:e}}});return{activities:i.data.ocs.data,lastGiven:i.headers["x-activity-last-given"],hasMore:String(i.headers.link??"").includes('rel="next"')}}catch(i){if(i.response!==void 0&&i.response.status===304)return{activities:[],lastGiven:void 0,hasMore:!1};throw i}},processActivities(t){t=t.map(i=>new K(i)),w.debug(`Processed ${t.length} activity(ies)`,{activities:t,node:this.node});const e=Z();return t.filter(i=>!e||e.every(s=>s(i)))},t:f}}),lt={key:0,class:"activity__actions"},dt={key:4,class:"activity__list"},ct={key:0,class:"activity__load-more"};function ht(t,e,i,s,r,m){const l=n("NcIconSvgWrapper"),h=n("NcEmptyContent"),j=n("ActivitySidebarPlugin"),x=n("DownloadSummary"),_=n("NcLoadingIcon"),L=n("ActivityComponent"),E=n("NcButton");return a(),o("div",{class:U([{"icon-loading":t.loading},"activity"])},[t.error||!t.node?(a(),d(h,{key:0,name:t.error},{icon:u(()=>[c(l,{svg:t.lightningBoltSVG},null,8,["svg"])]),_:1},8,["name"])):(a(),o(g,{key:1},[t.sidebarPlugins.length>0?(a(),o("div",lt,[(a(!0),o(g,null,G(t.sidebarPlugins,(v,A)=>(a(),d(j,{key:A,plugin:v,node:t.node,onReloadActivities:e[0]||(e[0]=vt=>t.getActivities())},null,8,["plugin","node"]))),128))])):y("",!0),t.hasPublicLink&&t.node.fileid?(a(),d(x,{key:1,fileId:t.node.fileid},null,8,["fileId"])):y("",!0),t.loading?(a(),d(h,{key:2,class:"activity__empty-content",name:t.t("activity","Loading activities")},{icon:u(()=>[c(_)]),_:1},8,["name"])):t.activities.length===0?(a(),d(h,{key:3,class:"activity__empty-content",name:t.t("activity","No activity yet")},{icon:u(()=>[c(l,{svg:t.lightningBoltSVG},null,8,["svg"])]),_:1},8,["name"])):(a(),o("ul",dt,[(a(!0),o(g,null,G(t.activities,v=>(a(),d(L,{key:v.id,activity:v,showPreviews:!1,onReload:e[1]||(e[1]=A=>t.getActivities())},null,8,["activity"]))),128)),t.hasMore?(a(),o("li",ct,[c(E,{variant:"tertiary",wide:"",disabled:t.loadingMore,onClick:e[2]||(e[2]=v=>t.loadMoreActivities())},F({default:u(()=>[O(" "+I(t.loadingMore?t.t("activity","Loading older activities…"):t.t("activity","Load older activities")),1)]),_:2},[t.loadingMore?{name:"icon",fn:u(()=>[c(_,{size:20})]),key:"0"}:void 0]),1032,["disabled"])])):y("",!0)]))],64))],2)}const bt=P(rt,[["render",ht],["__scopeId","data-v-242e244d"]]);export{bt as default};
//# sourceMappingURL=ActivityTab-89HemtnE.chunk.mjs.map
import{l as R}from"./lightning-bolt-CVnodBao.chunk.mjs";import{b as M,j as S,h as P,o as D,N as V}from"./NcCheckboxRadioSwitch-BVTMQSAg-C5AyK8PZ.chunk.mjs";import{d as C,x as q,B,y as T,a,c as o,j as H,W as p,J as f,m as n,e as k,f as c,t as I,E as y,l as W,b as d,g as u,F as g,K as G,a1 as F,h as O,n as U}from"./translation-DoG5ZELJ-eekoBSws.chunk.mjs";import{a as j}from"./index-BrNGPgve.chunk.mjs";import{j as z,f as J,A as K}from"./ActivityComponent.vue_vue_type_script_setup_true_lang-BEwcnFT1.chunk.mjs";import{l as w}from"./logger-CXg3FpL2.chunk.mjs";import{g as Z,a as $,b as Q}from"./api-fwrRGLr6.chunk.mjs";var b;(function(t){t[t.User=0]="User",t[t.Group=1]="Group",t[t.Link=3]="Link",t[t.Email=4]="Email",t[t.Remote=6]="Remote",t[t.Team=7]="Team",t[t.Guest=8]="Guest",t[t.RemoteGroup=9]="RemoteGroup",t[t.Room=10]="Room",t[t.Deck=12]="Deck",t[t.FederatedGroup=14]="FederatedGroup",t[t.ScienceMesh=15]="ScienceMesh"})(b||(b={}));const X=C({__name:"ActivitySidebarPlugin",props:{plugin:{},node:{}},emits:["reloadActivities"],setup(t,{emit:e}){const i=t,s=e,r=H();return q(()=>i.plugin.mount(r.value,{node:i.node,context:B()?.proxy??void 0,reload:()=>s("reloadActivities")})),T(()=>i.plugin.unmount()),(m,l)=>(a(),o("div",{ref_key:"attachTarget",ref:r},null,512))}}),Y='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-download-circle" viewBox="0 0 24 24"><path d="M12 2C17.5 2 22 6.5 22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2M8 17H16V15H8V17M16 10H13.5V6H10.5V10H8L12 14L16 10Z" /></svg>',tt=C({name:"DownloadSummary",components:{NcIconSvgWrapper:M},props:{fileId:{type:Number,required:!0}},data(){return{totalCount:0,monthlyCount:0,downloadSVG:Y}},computed:{summaryText(){return this.monthlyCount>0&&this.monthlyCount<this.totalCount?p("activity","Downloaded %n time (%s in the last 30 days)","Downloaded %n times (%s in the last 30 days)",this.totalCount,[String(this.monthlyCount)]):p("activity","Downloaded %n time","Downloaded %n times",this.totalCount)}},watch:{fileId:{immediate:!0,handler(){this.fetchCounts()}}},methods:{async fetchCounts(){if(this.fileId){this.totalCount=0,this.monthlyCount=0;try{const t=await S.get(j("apps/activity/api/v2/activity/downloads/count"),{params:{format:"json",object_type:"files",object_id:this.fileId}});this.totalCount=t.data.ocs.data.total,this.monthlyCount=t.data.ocs.data.last30d}catch(t){w.error("Failed to fetch download counts",{error:t})}}},t:f,n:p}}),it={key:0,class:"download-summary"},et={class:"download-summary__icon"},at={class:"download-summary__text"};function st(t,e,i,s,r,m){const l=n("NcIconSvgWrapper");return t.totalCount>0?(a(),o("div",it,[k("span",et,[c(l,{svg:t.downloadSVG,size:20},null,8,["svg"])]),k("span",at,I(t.summaryText),1)])):y("",!0)}const ot=P(tt,[["render",st],["__scopeId","data-v-81e4514f"]]),nt=50,rt=C({name:"ActivityTab",components:{ActivityComponent:J,DownloadSummary:ot,NcButton:V,NcEmptyContent:z,NcIconSvgWrapper:M,NcLoadingIcon:D,ActivitySidebarPlugin:X},props:{node:{type:Object,required:!0},folder:{type:Object,required:!1,default:void 0},view:{type:Object,required:!1,default:void 0}},expose:["update"],data(){return{error:"",loading:!0,loadingMore:!1,activities:[],lightningBoltSVG:R,sidebarPlugins:[],requestController:null,realActivities:[],otherEntries:[],lastGiven:void 0,hasMore:!1}},computed:{hasPublicLink(){return Object.values(this.node?.attributes?.["share-types"]??{}).flat().includes(b.Link)}},watch:{node:{immediate:!0,async handler(){await this.update()}}},beforeUnmount(){this.requestController?.abort()},methods:{async update(){this.sidebarPlugins=[];const t=Q();t.length>0&&W(()=>{this.sidebarPlugins=t}),this.resetState(),await this.getActivities()},async getActivities(){await this.fetchPage(!0)},async loadMoreActivities(){await this.fetchPage(!1)},async fetchPage(t){this.requestController?.abort();const e=new AbortController;this.requestController=e;const{signal:i}=e;try{t?this.loading=!0:this.loadingMore=!0;const s=await this.loadRealActivities(i,t?void 0:this.lastGiven),r=this.processActivities(s.activities),m=t?await $({node:this.node}):this.otherEntries;if(i.aborted)return;this.realActivities=t?r:[...this.realActivities,...r],this.otherEntries=m,(t||s.lastGiven!==void 0)&&(this.lastGiven=s.lastGiven),this.hasMore=s.hasMore,this.activities=[...this.realActivities,...this.otherEntries].sort((l,h)=>h.timestamp-l.timestamp)}catch(s){if(i.aborted)return;this.error=f("activity","Unable to load the activity list"),w.error("Error loading the activity list",{error:s})}finally{i.aborted||(this.loading=!1,this.loadingMore=!1)}},resetState(){this.loading=!0,this.loadingMore=!1,this.error="",this.activities=[],this.realActivities=[],this.otherEntries=[],this.lastGiven=void 0,this.hasMore=!1},async loadRealActivities(t,e){try{const i=await S.get(j("apps/activity/api/v2/activity/filter"),{signal:t,params:{format:"json",object_type:"files",object_id:this.node.fileid,limit:nt,...e===void 0?{}:{since:e}}});return{activities:i.data.ocs.data,lastGiven:i.headers["x-activity-last-given"],hasMore:String(i.headers.link??"").includes('rel="next"')}}catch(i){if(i.response!==void 0&&i.response.status===304)return{activities:[],lastGiven:void 0,hasMore:!1};throw i}},processActivities(t){t=t.map(i=>new K(i)),w.debug(`Processed ${t.length} activity(ies)`,{activities:t,node:this.node});const e=Z();return t.filter(i=>!e||e.every(s=>s(i)))},t:f}}),lt={key:0,class:"activity__actions"},dt={key:4,class:"activity__list"},ct={key:0,class:"activity__load-more"};function ht(t,e,i,s,r,m){const l=n("NcIconSvgWrapper"),h=n("NcEmptyContent"),N=n("ActivitySidebarPlugin"),x=n("DownloadSummary"),_=n("NcLoadingIcon"),L=n("ActivityComponent"),E=n("NcButton");return a(),o("div",{class:U([{"icon-loading":t.loading},"activity"])},[t.error||!t.node?(a(),d(h,{key:0,name:t.error},{icon:u(()=>[c(l,{svg:t.lightningBoltSVG},null,8,["svg"])]),_:1},8,["name"])):(a(),o(g,{key:1},[t.sidebarPlugins.length>0?(a(),o("div",lt,[(a(!0),o(g,null,G(t.sidebarPlugins,(v,A)=>(a(),d(N,{key:A,plugin:v,node:t.node,onReloadActivities:e[0]||(e[0]=vt=>t.getActivities())},null,8,["plugin","node"]))),128))])):y("",!0),t.hasPublicLink&&t.node.fileid?(a(),d(x,{key:1,fileId:t.node.fileid},null,8,["fileId"])):y("",!0),t.loading?(a(),d(h,{key:2,class:"activity__empty-content",name:t.t("activity","Loading activities")},{icon:u(()=>[c(_)]),_:1},8,["name"])):t.activities.length===0?(a(),d(h,{key:3,class:"activity__empty-content",name:t.t("activity","No activity yet")},{icon:u(()=>[c(l,{svg:t.lightningBoltSVG},null,8,["svg"])]),_:1},8,["name"])):(a(),o("ul",dt,[(a(!0),o(g,null,G(t.activities,v=>(a(),d(L,{key:v.id,activity:v,showPreviews:!1,onReload:e[1]||(e[1]=A=>t.getActivities())},null,8,["activity"]))),128)),t.hasMore?(a(),o("li",ct,[c(E,{variant:"tertiary",wide:"",disabled:t.loadingMore,onClick:e[2]||(e[2]=v=>t.loadMoreActivities())},F({default:u(()=>[O(" "+I(t.loadingMore?t.t("activity","Loading older activities…"):t.t("activity","Load older activities")),1)]),_:2},[t.loadingMore?{name:"icon",fn:u(()=>[c(_,{size:20})]),key:"0"}:void 0]),1032,["disabled"])])):y("",!0)]))],64))],2)}const bt=P(rt,[["render",ht],["__scopeId","data-v-242e244d"]]);export{bt as default};
//# sourceMappingURL=ActivityTab-G1_ISy-N.chunk.mjs.map

Large diffs are not rendered by default.

Loading
Loading